FreeCAD workbench to create assembly handbooks
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

33 lines
1.3 KiB

from typing import Optional
import FreeCADGui as Gui
import FreeCAD as App
class AHB_SetPartStage:
def GetResources(self):
return {"MenuText": "Set part stage",
"ToolTip": "Sets the stage for this part to the currently active stage",
"Pixmap": ""
}
def IsActive(self):
return True
def Activated(self, stageId: Optional[int] = None):
workbench = Gui.getWorkbench("AssemblyHandbookWorkbench")
if stageId is None:
stageId = workbench.context.getActiveStage()
if stageId is None:
raise BaseException("You must activate a stage before using this command")
obj: App.DocumentObject
for obj in Gui.Selection.getSelection():
if obj is not None and obj.TypeId == 'Part::Feature':
if not "AssemblyHandbook_Stage" in obj.PropertiesList:
obj.addProperty("App::PropertyInteger", "AssemblyHandbook_Stage", "AssemblyHandbook")
if obj.AssemblyHandbook_Stage != stageId:
obj.AssemblyHandbook_Stage = stageId
workbench.context.onPartStageChanged(obj)
from ahb_command import AHB_CommandWrapper
AHB_CommandWrapper.addGuiCommand('AHB_setPartStage', AHB_SetPartStage())