import FreeCADGui as Gui import FreeCAD as App import ahb_utils 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 = ahb_utils.getCurrentView() 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())