Youen
2 years ago
4 changed files with 52 additions and 3 deletions
@ -0,0 +1,30 @@ |
|||||||
|
import FreeCADGui as Gui |
||||||
|
import FreeCAD as App |
||||||
|
|
||||||
|
class AHB_SetViewDirection: |
||||||
|
def GetResources(self): |
||||||
|
return {"MenuText": "Set view direction", |
||||||
|
"ToolTip": "Applies the current 3D view direction on the selected TechDraw view", |
||||||
|
"Pixmap": "" |
||||||
|
} |
||||||
|
|
||||||
|
def IsActive(self): |
||||||
|
view = self._get_view() |
||||||
|
return view is not None |
||||||
|
|
||||||
|
def Activated(self): |
||||||
|
workbench = Gui.getWorkbench("AssemblyHandbookWorkbench") #: :type workbench: AssemblyHandbookWorkbench |
||||||
|
view = self._get_view() |
||||||
|
if view is None: |
||||||
|
raise Exception("Please select a TechDraw view") |
||||||
|
workbench.techDrawExtensions.setCurrentViewDirection(view) |
||||||
|
|
||||||
|
def _get_view(self): |
||||||
|
view = None if len(Gui.Selection.getSelection()) == 0 else Gui.Selection.getSelection()[0] |
||||||
|
if view is not None and view.TypeId != 'TechDraw::DrawViewPart': |
||||||
|
view = None |
||||||
|
return view |
||||||
|
|
||||||
|
|
||||||
|
from ahb_command import AHB_CommandWrapper |
||||||
|
AHB_CommandWrapper.addGuiCommand('AHB_view_set_direction', AHB_SetViewDirection()) |
Loading…
Reference in new issue