|
|
@ -1,6 +1,7 @@ |
|
|
|
import FreeCADGui as Gui |
|
|
|
import FreeCADGui as Gui |
|
|
|
import FreeCAD as App |
|
|
|
import FreeCAD as App |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import ahb_utils |
|
|
|
class AHB_SetViewDirection: |
|
|
|
class AHB_SetViewDirection: |
|
|
|
def GetResources(self): |
|
|
|
def GetResources(self): |
|
|
|
return {"MenuText": "Set view direction", |
|
|
|
return {"MenuText": "Set view direction", |
|
|
@ -9,22 +10,15 @@ class AHB_SetViewDirection: |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
def IsActive(self): |
|
|
|
def IsActive(self): |
|
|
|
view = self._get_view() |
|
|
|
return ahb_utils.getCurrentView() is not None |
|
|
|
return view is not None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def Activated(self): |
|
|
|
def Activated(self): |
|
|
|
workbench = Gui.getWorkbench("AssemblyHandbookWorkbench") #: :type workbench: AssemblyHandbookWorkbench |
|
|
|
workbench = Gui.getWorkbench("AssemblyHandbookWorkbench") #: :type workbench: AssemblyHandbookWorkbench |
|
|
|
view = self._get_view() |
|
|
|
view = ahb_utils.getCurrentView() |
|
|
|
if view is None: |
|
|
|
if view is None: |
|
|
|
raise Exception("Please select a TechDraw view") |
|
|
|
raise Exception("Please select a TechDraw view") |
|
|
|
workbench.techDrawExtensions.setCurrentViewDirection(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 |
|
|
|
from ahb_command import AHB_CommandWrapper |
|
|
|
AHB_CommandWrapper.addGuiCommand('AHB_view_set_direction', AHB_SetViewDirection()) |
|
|
|
AHB_CommandWrapper.addGuiCommand('AHB_view_set_direction', AHB_SetViewDirection()) |
|
|
|