Skip to content

Commit

Permalink
fixes issue aligning workplane to a face
Browse files Browse the repository at this point in the history
this is a quick workaround for a problem introduced in the Draft select plane procedure while refactoring the code. not sure it is the best fix though.
  • Loading branch information
hvfrancesco authored and yorikvanhavre committed Oct 7, 2019
1 parent fcda093 commit e325f2e
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/Mod/Draft/DraftSelectPlane.py
Expand Up @@ -74,17 +74,6 @@ def Activated(self):
p = FreeCAD.DraftWorkingPlane
self.states.append([p.u, p.v, p.axis, p.position])

# try to find a WP from the current selection
if self.handle():
return

# try other method
if FreeCAD.DraftWorkingPlane.alignToSelection():
FreeCADGui.Selection.clearSelection()
self.display(FreeCAD.DraftWorkingPlane.axis)
self.finish()
return

m = translate("draft", "Pick a face, 3 vertices or a WP Proxy to define the drawing plane")
FreeCAD.Console.PrintMessage(m+"\n")

Expand Down Expand Up @@ -123,8 +112,19 @@ def Activated(self):
self.taskd.form.buttonPrevious.clicked.connect(self.onClickPrevious)
self.taskd.form.fieldGridSpacing.textEdited.connect(self.onSetGridSize)
self.taskd.form.fieldGridMainLine.valueChanged.connect(self.onSetMainline)
self.taskd.form.fieldSnapRadius.valueChanged.connect(self.onSetSnapRadius)
self.taskd.form.fieldSnapRadius.valueChanged.connect(self.onSetSnapRadius)

# try to find a WP from the current selection
if self.handle():
return

# try other method
if FreeCAD.DraftWorkingPlane.alignToSelection():
FreeCADGui.Selection.clearSelection()
self.display(FreeCAD.DraftWorkingPlane.axis)
self.finish()
return

# rock 'n roll!
FreeCADGui.Control.showDialog(self.taskd)
self.call = self.view.addEventCallback("SoEvent", self.action)
Expand Down Expand Up @@ -239,7 +239,7 @@ def handle(self):
elif sel.HasSubObjects:
if len(sel.SubElementNames) == 1:
if "Face" in sel.SubElementNames[0]:
FreeCAD.DraftWorkingPlane.alignToFace(sel.SubObjects[0], self.taskd.form.fieldOffset.Value)
FreeCAD.DraftWorkingPlane.alignToFace(sel.SubObjects[0], self.getOffset())
self.display(FreeCAD.DraftWorkingPlane.axis)
return True
elif sel.SubElementNames[0] == "Plane":
Expand All @@ -253,13 +253,13 @@ def handle(self):
FreeCAD.DraftWorkingPlane.alignTo3Points(sel.SubObjects[0].Point,
sel.SubObjects[1].Point,
sel.SubObjects[2].Point,
self.taskd.form.fieldOffset.Value)
self.getOffset())
self.display(FreeCAD.DraftWorkingPlane.axis)
return True
elif sel.Object.isDerivedFrom("Part::Feature"):
if sel.Object.Shape:
if len(sel.Object.Shape.Faces) == 1:
FreeCAD.DraftWorkingPlane.alignToFace(sel.Object.Shape.Faces[0], self.taskd.form.fieldOffset.Value)
FreeCAD.DraftWorkingPlane.alignToFace(sel.Object.Shape.Faces[0], self.getOffset())
self.display(FreeCAD.DraftWorkingPlane.axis)
return True
elif sel:
Expand All @@ -273,7 +273,7 @@ def handle(self):
FreeCAD.DraftWorkingPlane.alignTo3Points(subs[0].Point,
subs[1].Point,
subs[2].Point,
self.taskd.form.fieldOffset.Value)
self.getOffset())
self.display(FreeCAD.DraftWorkingPlane.axis)
return True
return False
Expand Down

0 comments on commit e325f2e

Please sign in to comment.