* FHNode continue function and FHPath bug fix
- Implementation of the FHNode 'continue' function as in the Draft workbench - Fix of FHNode creation from a Draft Point object - Fix of FHPath creation with non-detected coincident nodes due to too strict tolerance w.r.t. FreeCAD allowed tolerance
This commit is contained in:
parent
1f6777dd8f
commit
f96aa6eb17
|
@ -33,7 +33,7 @@ __url__ = "http://www.fastfieldsolvers.com"
|
||||||
# defines
|
# defines
|
||||||
#
|
#
|
||||||
# tolerance in distance between nodes to define a port
|
# tolerance in distance between nodes to define a port
|
||||||
EMFHEQUIV_LENTOL = 1e-12
|
EMFHEQUIV_LENTOL = 1e-8
|
||||||
|
|
||||||
import FreeCAD, FreeCADGui, Mesh, Part, MeshPart, Draft, DraftGeomUtils, os
|
import FreeCAD, FreeCADGui, Mesh, Part, MeshPart, Draft, DraftGeomUtils, os
|
||||||
from FreeCAD import Vector
|
from FreeCAD import Vector
|
||||||
|
|
38
EM_FHNode.py
38
EM_FHNode.py
|
@ -296,6 +296,9 @@ class _CommandFHNode:
|
||||||
# get the selected object(s)
|
# get the selected object(s)
|
||||||
sel = FreeCADGui.Selection.getSelectionEx()
|
sel = FreeCADGui.Selection.getSelectionEx()
|
||||||
done = False
|
done = False
|
||||||
|
# set continue mode to false, as default (continue or not to place FHNodes
|
||||||
|
# without the need to press again the FHNode button)
|
||||||
|
self.continueCmd = False
|
||||||
# if selection is not empty
|
# if selection is not empty
|
||||||
if sel:
|
if sel:
|
||||||
# automatic mode
|
# automatic mode
|
||||||
|
@ -304,7 +307,7 @@ class _CommandFHNode:
|
||||||
FreeCAD.ActiveDocument.openTransaction(translate("EM","Create FHNode"))
|
FreeCAD.ActiveDocument.openTransaction(translate("EM","Create FHNode"))
|
||||||
FreeCADGui.addModule("EM")
|
FreeCADGui.addModule("EM")
|
||||||
for selobj in sel:
|
for selobj in sel:
|
||||||
if Draft.getType(selobj) == "Point":
|
if Draft.getType(selobj.Object) == "Point":
|
||||||
FreeCADGui.doCommand('obj=EM.makeFHNode(FreeCAD.ActiveDocument.'+selobj.Object.Name+')')
|
FreeCADGui.doCommand('obj=EM.makeFHNode(FreeCAD.ActiveDocument.'+selobj.Object.Name+')')
|
||||||
# autogrouping, for later on
|
# autogrouping, for later on
|
||||||
#FreeCADGui.addModule("Draft")
|
#FreeCADGui.addModule("Draft")
|
||||||
|
@ -316,7 +319,7 @@ class _CommandFHNode:
|
||||||
if not done:
|
if not done:
|
||||||
FreeCAD.DraftWorkingPlane.setup()
|
FreeCAD.DraftWorkingPlane.setup()
|
||||||
# get a 3D point via Snapper, setting the callback functions
|
# get a 3D point via Snapper, setting the callback functions
|
||||||
FreeCADGui.Snapper.getPoint(callback=self.getPoint,movecallback=self.move)
|
FreeCADGui.Snapper.getPoint(callback=self.getPoint,movecallback=self.move,extradlg=self.taskbox())
|
||||||
|
|
||||||
def getPoint(self,point=None,obj=None):
|
def getPoint(self,point=None,obj=None):
|
||||||
'''This function is called by the Snapper when it has a 3D point'''
|
'''This function is called by the Snapper when it has a 3D point'''
|
||||||
|
@ -328,9 +331,9 @@ class _CommandFHNode:
|
||||||
FreeCADGui.doCommand('obj=EM.makeFHNode(X='+str(coord.x)+',Y='+str(coord.y)+',Z='+str(coord.z)+')')
|
FreeCADGui.doCommand('obj=EM.makeFHNode(X='+str(coord.x)+',Y='+str(coord.y)+',Z='+str(coord.z)+')')
|
||||||
FreeCAD.ActiveDocument.commitTransaction()
|
FreeCAD.ActiveDocument.commitTransaction()
|
||||||
FreeCAD.ActiveDocument.recompute()
|
FreeCAD.ActiveDocument.recompute()
|
||||||
# might improve in the future with continue command
|
# handle continue command
|
||||||
#if self.continueCmd:
|
if self.continueCmd:
|
||||||
# self.Activated()
|
self.Activated()
|
||||||
|
|
||||||
# this is used to display the global point position information
|
# this is used to display the global point position information
|
||||||
# in the Snapper user interface. By default it would display the relative
|
# in the Snapper user interface. By default it would display the relative
|
||||||
|
@ -339,6 +342,31 @@ class _CommandFHNode:
|
||||||
def move(self,point=None,snapInfo=None):
|
def move(self,point=None,snapInfo=None):
|
||||||
if FreeCADGui.Snapper.ui:
|
if FreeCADGui.Snapper.ui:
|
||||||
FreeCADGui.Snapper.ui.displayPoint(point)
|
FreeCADGui.Snapper.ui.displayPoint(point)
|
||||||
|
|
||||||
|
def taskbox(self):
|
||||||
|
"sets up a taskbox widget"
|
||||||
|
w = QtGui.QWidget()
|
||||||
|
ui = FreeCADGui.UiLoader()
|
||||||
|
w.setWindowTitle(translate("EM","FHNode options", utf8_decode=True))
|
||||||
|
grid = QtGui.QGridLayout(w)
|
||||||
|
|
||||||
|
label4 = QtGui.QLabel(translate("EM","Con&tinue", utf8_decode=True))
|
||||||
|
value4 = QtGui.QCheckBox()
|
||||||
|
value4.setObjectName("ContinueCmd")
|
||||||
|
value4.setLayoutDirection(QtCore.Qt.RightToLeft)
|
||||||
|
label4.setBuddy(value4)
|
||||||
|
if hasattr(FreeCADGui,"draftToolBar"):
|
||||||
|
value4.setChecked(FreeCADGui.draftToolBar.continueMode)
|
||||||
|
self.continueCmd = FreeCADGui.draftToolBar.continueMode
|
||||||
|
grid.addWidget(label4,1,0,1,1)
|
||||||
|
grid.addWidget(value4,1,1,1,1)
|
||||||
|
QtCore.QObject.connect(value4,QtCore.SIGNAL("stateChanged(int)"),self.setContinue)
|
||||||
|
return w
|
||||||
|
|
||||||
|
def setContinue(self,i):
|
||||||
|
self.continueCmd = bool(i)
|
||||||
|
if hasattr(FreeCADGui,"draftToolBar"):
|
||||||
|
FreeCADGui.draftToolBar.continueMode = bool(i)
|
||||||
|
|
||||||
if FreeCAD.GuiUp:
|
if FreeCAD.GuiUp:
|
||||||
FreeCADGui.addCommand('EM_FHNode',_CommandFHNode())
|
FreeCADGui.addCommand('EM_FHNode',_CommandFHNode())
|
||||||
|
|
|
@ -338,7 +338,7 @@ class _CommandFHPlaneHole:
|
||||||
FreeCAD.ActiveDocument.openTransaction(translate("EM","Create FHPlaneHole"))
|
FreeCAD.ActiveDocument.openTransaction(translate("EM","Create FHPlaneHole"))
|
||||||
FreeCADGui.addModule("EM")
|
FreeCADGui.addModule("EM")
|
||||||
for selobj in sel:
|
for selobj in sel:
|
||||||
if Draft.getType(selobj) == "Point":
|
if Draft.getType(selobj.Object) == "Point":
|
||||||
FreeCADGui.doCommand('obj=EM.makeFHPlaneHole(FreeCAD.ActiveDocument.'+selobj.Object.Name+')')
|
FreeCADGui.doCommand('obj=EM.makeFHPlaneHole(FreeCAD.ActiveDocument.'+selobj.Object.Name+')')
|
||||||
# autogrouping, for later on
|
# autogrouping, for later on
|
||||||
#FreeCADGui.addModule("Draft")
|
#FreeCADGui.addModule("Draft")
|
||||||
|
|
|
@ -31,7 +31,7 @@ __url__ = "http://www.fastfieldsolvers.com"
|
||||||
# defines
|
# defines
|
||||||
#
|
#
|
||||||
# tolerance in distance between nodes to define a port
|
# tolerance in distance between nodes to define a port
|
||||||
EMFHPORT_LENTOL = 1e-12
|
EMFHPORT_LENTOL = 1e-8
|
||||||
|
|
||||||
import FreeCAD, FreeCADGui, Mesh, Part, MeshPart, Draft, DraftGeomUtils, os
|
import FreeCAD, FreeCADGui, Mesh, Part, MeshPart, Draft, DraftGeomUtils, os
|
||||||
from FreeCAD import Vector
|
from FreeCAD import Vector
|
||||||
|
|
|
@ -38,7 +38,7 @@ EMFHNODE_DEF_NODECOLOR = (1.0,0.0,0.0)
|
||||||
# tolerance in degrees when verifying if vectors are parallel
|
# tolerance in degrees when verifying if vectors are parallel
|
||||||
EMFHSEGMENT_PARTOL = 0.01
|
EMFHSEGMENT_PARTOL = 0.01
|
||||||
# tolerance in length
|
# tolerance in length
|
||||||
EMFHSEGMENT_LENTOL = 1e-12
|
EMFHSEGMENT_LENTOL = 1e-8
|
||||||
|
|
||||||
import FreeCAD, Part
|
import FreeCAD, Part
|
||||||
from FreeCAD import Vector
|
from FreeCAD import Vector
|
||||||
|
|
Loading…
Reference in New Issue
Block a user