import FreeCADGui FreeCADGui.activateWorkbench("PartDesignWorkbench")
import FreeCADGui class MyCommand: def __init__(self): self.obj = FreeCAD.ActiveDocument.addObject("Part::Box", "Box") def Activated(self): self.obj.ViewObject.Visibility = not self.obj.ViewObject.Visibility def GetResources(self): return {'Pixmap': '/path/to/icon', 'MenuText': 'My Command', 'ToolTip': 'My Command Description'} FreeCADGui.addCommand('My Command', MyCommand())This code snippet creates a custom command named 'My Command' which adds a box object to the active document and toggles its visibility when activated. It also adds a toolbar button with a custom icon and tooltip to activate the command. Package library: FreeCADGui is part of FreeCAD's Python API module library.