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.

62 lines
2.8 KiB

import FreeCADGui as Gui
import FreeCAD as App
class AHB_EditViewSourceParts:
def GetResources(self):
return {"MenuText": "Edit view source parts",
"ToolTip": "Edits the list of parts that will be rendered in the selected TechDraw view",
"Pixmap": ""
}
def IsActive(self):
workbench = Gui.getWorkbench("AssemblyHandbookWorkbench") #: :type workbench: AssemblyHandbookWorkbench
edit_mode = workbench.techDrawExtensions.edited_view is not None
if edit_mode:
return True
else:
return len(Gui.Selection.getSelection()) == 1 and Gui.Selection.getSelection()[0].TypeId == 'TechDraw::DrawViewPart'
def Activated(self):
workbench = Gui.getWorkbench("AssemblyHandbookWorkbench") #: :type workbench: AssemblyHandbookWorkbench
view = None
if len(Gui.Selection.getSelection()) == 1 and Gui.Selection.getSelection()[0].TypeId == 'TechDraw::DrawViewPart':
view = Gui.Selection.getSelection()[0]
workbench.techDrawExtensions.toggleEditViewSourceParts(view)
class AHB_AddSourcePartsToView:
def GetResources(self):
return {"MenuText": "Add",
"ToolTip": "Adds the selected part(s) to the currently edited view",
"Pixmap": ""
}
def IsActive(self):
workbench = Gui.getWorkbench("AssemblyHandbookWorkbench") #: :type workbench: AssemblyHandbookWorkbench
edit_mode = workbench.techDrawExtensions.edited_view is not None
return edit_mode
def Activated(self):
workbench = Gui.getWorkbench("AssemblyHandbookWorkbench") #: :type workbench: AssemblyHandbookWorkbench
workbench.techDrawExtensions.editViewSourceParts(Gui.Selection.getSelection(), True)
class AHB_RemoveSourcePartsToView:
def GetResources(self):
return {"MenuText": "Remove",
"ToolTip": "Removes the selected part(s) from the currently edited view",
"Pixmap": ""
}
def IsActive(self):
workbench = Gui.getWorkbench("AssemblyHandbookWorkbench") #: :type workbench: AssemblyHandbookWorkbench
edit_mode = workbench.techDrawExtensions.edited_view is not None
return edit_mode
def Activated(self):
workbench = Gui.getWorkbench("AssemblyHandbookWorkbench") #: :type workbench: AssemblyHandbookWorkbench
workbench.techDrawExtensions.editViewSourceParts(Gui.Selection.getSelection(), False)
from ahb_command import AHB_CommandWrapper
AHB_CommandWrapper.addGuiCommand('AHB_view_edit_source_parts', AHB_EditViewSourceParts())
AHB_CommandWrapper.addGuiCommand('AHB_view_add_source_parts', AHB_AddSourcePartsToView())
AHB_CommandWrapper.addGuiCommand('AHB_view_remove_source_parts', AHB_RemoveSourcePartsToView())