forked from youen/assembly_handbook
Youen
2 years ago
6 changed files with 195 additions and 28 deletions
@ -0,0 +1,62 @@
|
||||
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()) |
Loading…
Reference in new issue