import DraftTools if Snapper isn't loaded yet (before using it)

This commit is contained in:
Markus Lampert
2021-02-07 12:38:39 -08:00
parent a3fb41502b
commit 394a885929
2 changed files with 7 additions and 0 deletions

View File

@@ -106,6 +106,10 @@ class TaskPanel:
If start is specified the Snapper UI is closed on the first point the user enters. If start remains None, then Snapper is kept open
until the user explicitly closes Snapper. This lets the user enter multiple points in quick succession.'''
# there's no get point without Snapper, if it's not loaded, need to do that explicitly
if not hasattr(FreeCADGui, 'Snapper'):
import DraftTools
def displayPoint(p):
self.point = p
self.formPoint.globalX.setProperty('rawValue', p.x)
@@ -175,6 +179,7 @@ class TaskPanel:
if self.buttonBox:
self.buttonBox.setEnabled(False)
FreeCADGui.Snapper.forceGridOff=True
def pointFinish(self, ok, cleanup = True):

View File

@@ -1265,6 +1265,8 @@ class CommandSetStartPoint:
obj.StartPoint.z = obj.ClearanceHeight.Value
def Activated(self):
if not hasattr(FreeCADGui, 'Snapper'):
import DraftTools
FreeCADGui.Snapper.getPoint(callback=self.setpoint)