Merge branch 'master' into path_helix
This commit is contained in:
@@ -36,6 +36,7 @@ if FreeCAD.GuiUp:
|
||||
# Qt tanslation handling
|
||||
try:
|
||||
_encoding = QtGui.QApplication.UnicodeUTF8
|
||||
|
||||
def translate(context, text, disambig=None):
|
||||
return QtGui.QApplication.translate(context, text, disambig, _encoding)
|
||||
except AttributeError:
|
||||
@@ -51,66 +52,49 @@ __url__ = "http://www.freecadweb.org"
|
||||
|
||||
"""Path Contour object and FreeCAD command"""
|
||||
|
||||
|
||||
class ObjectContour:
|
||||
|
||||
def __init__(self, obj):
|
||||
obj.addProperty("App::PropertyBool", "Active", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","Make False, to prevent operation from generating code"))
|
||||
obj.addProperty("App::PropertyBool", "Active", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "Make False, to prevent operation from generating code"))
|
||||
obj.addProperty("App::PropertyString", "Comment", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "An optional comment for this Contour"))
|
||||
obj.addProperty("App::PropertyString", "UserLabel", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","User Assigned Label"))
|
||||
obj.addProperty("App::PropertyString", "UserLabel", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "User Assigned Label"))
|
||||
|
||||
obj.addProperty("App::PropertyIntegerConstraint", "ToolNumber", "Tool", QtCore.QT_TRANSLATE_NOOP("App::Property","The tool number in use"))
|
||||
obj.addProperty("App::PropertyIntegerConstraint", "ToolNumber", "Tool", QtCore.QT_TRANSLATE_NOOP("App::Property", "The tool number in use"))
|
||||
obj.ToolNumber = (0, 0, 1000, 1)
|
||||
obj.setEditorMode('ToolNumber', 1) # make this read only
|
||||
obj.addProperty("App::PropertyString", "ToolDescription", "Tool", QtCore.QT_TRANSLATE_NOOP("App::Property","The description of the tool "))
|
||||
obj.setEditorMode('ToolDescription', 1) # make this read only
|
||||
obj.addProperty("App::PropertyString", "ToolDescription", "Tool", QtCore.QT_TRANSLATE_NOOP("App::Property", "The description of the tool "))
|
||||
obj.setEditorMode('ToolDescription', 1) # make this read only
|
||||
|
||||
# Depth Properties
|
||||
obj.addProperty("App::PropertyDistance", "ClearanceHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","The height needed to clear clamps and obstructions"))
|
||||
obj.addProperty("App::PropertyDistance", "SafeHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","Rapid Safety Height between locations."))
|
||||
obj.addProperty("App::PropertyDistance", "StepDown", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","Incremental Step Down of Tool"))
|
||||
#obj.StepDown = (1, 0.01, 1000, 0.5)
|
||||
obj.addProperty("App::PropertyDistance", "StartDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","Starting Depth of Tool- first cut depth in Z"))
|
||||
obj.addProperty("App::PropertyDistance", "FinalDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","Final Depth of Tool- lowest value in Z"))
|
||||
obj.addProperty("App::PropertyDistance", "ClearanceHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "The height needed to clear clamps and obstructions"))
|
||||
obj.addProperty("App::PropertyDistance", "SafeHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Rapid Safety Height between locations."))
|
||||
obj.addProperty("App::PropertyDistance", "StepDown", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Incremental Step Down of Tool"))
|
||||
obj.addProperty("App::PropertyDistance", "StartDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Starting Depth of Tool- first cut depth in Z"))
|
||||
obj.addProperty("App::PropertyDistance", "FinalDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Final Depth of Tool- lowest value in Z"))
|
||||
|
||||
# Start Point Properties
|
||||
obj.addProperty("App::PropertyVector", "StartPoint", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property","The start point of this path"))
|
||||
obj.addProperty("App::PropertyBool", "UseStartPoint", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property","make True, if specifying a Start Point"))
|
||||
obj.addProperty("App::PropertyLength", "ExtendAtStart", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property","extra length of tool path before start of part edge"))
|
||||
obj.addProperty("App::PropertyLength", "LeadInLineLen", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property","length of straight segment of toolpath that comes in at angle to first part edge"))
|
||||
obj.addProperty("App::PropertyVector", "StartPoint", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "The start point of this path"))
|
||||
obj.addProperty("App::PropertyBool", "UseStartPoint", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "make True, if specifying a Start Point"))
|
||||
obj.addProperty("App::PropertyLength", "ExtendAtStart", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "extra length of tool path before start of part edge"))
|
||||
obj.addProperty("App::PropertyLength", "LeadInLineLen", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "length of straight segment of toolpath that comes in at angle to first part edge"))
|
||||
|
||||
# End Point Properties
|
||||
obj.addProperty("App::PropertyBool", "UseEndPoint", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property","make True, if specifying an End Point"))
|
||||
obj.addProperty("App::PropertyLength", "ExtendAtEnd", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property","extra length of tool path after end of part edge"))
|
||||
obj.addProperty("App::PropertyLength", "LeadOutLineLen", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property","length of straight segment of toolpath that comes in at angle to last part edge"))
|
||||
obj.addProperty("App::PropertyVector", "EndPoint", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property","The end point of this path"))
|
||||
obj.addProperty("App::PropertyBool", "UseEndPoint", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "make True, if specifying an End Point"))
|
||||
obj.addProperty("App::PropertyLength", "ExtendAtEnd", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "extra length of tool path after end of part edge"))
|
||||
obj.addProperty("App::PropertyLength", "LeadOutLineLen", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "length of straight segment of toolpath that comes in at angle to last part edge"))
|
||||
obj.addProperty("App::PropertyVector", "EndPoint", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "The end point of this path"))
|
||||
|
||||
# Contour Properties
|
||||
obj.addProperty("App::PropertyEnumeration", "Direction", "Contour", QtCore.QT_TRANSLATE_NOOP("App::Property","The direction that the toolpath should go around the part ClockWise CW or CounterClockWise CCW"))
|
||||
obj.addProperty("App::PropertyEnumeration", "Direction", "Contour", QtCore.QT_TRANSLATE_NOOP("App::Property", "The direction that the toolpath should go around the part ClockWise CW or CounterClockWise CCW"))
|
||||
obj.Direction = ['CW', 'CCW'] # this is the direction that the Contour runs
|
||||
obj.addProperty("App::PropertyBool", "UseComp", "Contour", QtCore.QT_TRANSLATE_NOOP("App::Property","make True, if using Cutter Radius Compensation"))
|
||||
obj.addProperty("App::PropertyBool", "UseComp", "Contour", QtCore.QT_TRANSLATE_NOOP("App::Property", "make True, if using Cutter Radius Compensation"))
|
||||
obj.addProperty("App::PropertyEnumeration", "Side", "Contour", QtCore.QT_TRANSLATE_NOOP("App::Property", "Side of edge that tool should cut"))
|
||||
obj.Side = ['Left', 'Right', 'On'] # side of profile that cutter is on in relation to direction of profile
|
||||
obj.setEditorMode('Side', 2) # hide
|
||||
obj.setEditorMode('Side', 2) # hide
|
||||
|
||||
obj.addProperty("App::PropertyDistance", "RollRadius", "Contour", QtCore.QT_TRANSLATE_NOOP("App::Property","Radius at start and end"))
|
||||
obj.addProperty("App::PropertyDistance", "OffsetExtra", "Contour", QtCore.QT_TRANSLATE_NOOP("App::Property","Extra value to stay away from final Contour- good for roughing toolpath"))
|
||||
obj.addProperty("App::PropertyLength", "SegLen", "Contour", QtCore.QT_TRANSLATE_NOOP("App::Property","Tesselation value for tool paths made from beziers, bsplines, and ellipses"))
|
||||
obj.addProperty("App::PropertyAngle", "PlungeAngle", "Contour", QtCore.QT_TRANSLATE_NOOP("App::Property","Plunge angle with which the tool enters the work piece. Straight down is 90 degrees, if set small enough or zero the tool will descent exactly one layer depth down per turn"))
|
||||
|
||||
obj.addProperty("App::PropertyVectorList", "locs", "Tags", QtCore.QT_TRANSLATE_NOOP("App::Property","List of holding tag locations"))
|
||||
|
||||
obj.addProperty("App::PropertyFloatList", "angles", "Tags", QtCore.QT_TRANSLATE_NOOP("App::Property","List of angles for the holding tags"))
|
||||
obj.addProperty("App::PropertyFloatList", "heights", "Tags", QtCore.QT_TRANSLATE_NOOP("App::Property","List of angles for the holding tags"))
|
||||
obj.addProperty("App::PropertyFloatList", "lengths", "Tags", QtCore.QT_TRANSLATE_NOOP("App::Property","List of angles for the holding tags"))
|
||||
locations = []
|
||||
angles = []
|
||||
lengths = []
|
||||
heights = []
|
||||
|
||||
obj.locs = locations
|
||||
obj.angles = angles
|
||||
obj.lengths = lengths
|
||||
obj.heights = heights
|
||||
obj.addProperty("App::PropertyDistance", "RollRadius", "Contour", QtCore.QT_TRANSLATE_NOOP("App::Property", "Radius at start and end"))
|
||||
obj.addProperty("App::PropertyDistance", "OffsetExtra", "Contour", QtCore.QT_TRANSLATE_NOOP("App::Property", "Extra value to stay away from final Contour- good for roughing toolpath"))
|
||||
|
||||
obj.Proxy = self
|
||||
|
||||
@@ -151,8 +135,8 @@ class ObjectContour:
|
||||
|
||||
def _buildPathLibarea(self, obj, edgelist):
|
||||
import PathScripts.PathKurveUtils as PathKurveUtils
|
||||
import math
|
||||
import area
|
||||
# import math
|
||||
# import area
|
||||
output = ""
|
||||
if obj.Comment != "":
|
||||
output += '(' + str(obj.Comment)+')\n'
|
||||
@@ -188,14 +172,6 @@ class ObjectContour:
|
||||
else:
|
||||
obj.Side = 'Right'
|
||||
|
||||
PathKurveUtils.clear_tags()
|
||||
for i in range(len(obj.locs)):
|
||||
tag = obj.locs[i]
|
||||
h = obj.heights[i]
|
||||
l = obj.lengths[i]
|
||||
a = math.radians(obj.angles[i])
|
||||
PathKurveUtils.add_tag(area.Point(tag.x, tag.y), l, a, h)
|
||||
|
||||
depthparams = depth_params(
|
||||
obj.ClearanceHeight.Value,
|
||||
obj.SafeHeight.Value, obj.StartDepth.Value, obj.StepDown.Value, 0.0,
|
||||
@@ -251,7 +227,7 @@ class ObjectContour:
|
||||
baseobject = parentJob.Base
|
||||
if baseobject is None:
|
||||
return
|
||||
contourwire = TechDraw.findShapeOutline(baseobject.Shape,1, Vector(0,0,1))
|
||||
contourwire = TechDraw.findShapeOutline(baseobject.Shape, 1, Vector(0, 0, 1))
|
||||
|
||||
edgelist = contourwire.Edges
|
||||
edgelist = Part.__sortEdges__(edgelist)
|
||||
@@ -298,45 +274,9 @@ class _ViewProviderContour:
|
||||
return None
|
||||
|
||||
|
||||
class _CommandAddTag:
|
||||
def GetResources(self):
|
||||
return {'Pixmap': 'Path-Holding',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Path_Contour", "Add Holding Tag"),
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Path_Contour", "Add Holding Tag")}
|
||||
|
||||
def IsActive(self):
|
||||
return FreeCAD.ActiveDocument is not None
|
||||
|
||||
def setpoint(self, point, o):
|
||||
obj = FreeCADGui.Selection.getSelection()[0]
|
||||
obj.StartPoint.x = point.x
|
||||
obj.StartPoint.y = point.y
|
||||
loc = obj.locs
|
||||
h = obj.heights
|
||||
l = obj.lengths
|
||||
a = obj.angles
|
||||
|
||||
x = point.x
|
||||
y = point.y
|
||||
z = float(0.0)
|
||||
loc.append(Vector(x, y, z))
|
||||
h.append(4.0)
|
||||
l.append(5.0)
|
||||
a.append(45.0)
|
||||
|
||||
obj.locs = loc
|
||||
obj.heights = h
|
||||
obj.lengths = l
|
||||
obj.angles = a
|
||||
|
||||
def Activated(self):
|
||||
|
||||
FreeCADGui.Snapper.getPoint(callback=self.setpoint)
|
||||
|
||||
|
||||
class _CommandSetStartPoint:
|
||||
def GetResources(self):
|
||||
return {'Pixmap': 'Path-Holding',
|
||||
return {'Pixmap': 'Path-StartPoint',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Path_Contour", "Pick Start Point"),
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Path_Contour", "Pick Start Point")}
|
||||
|
||||
@@ -355,7 +295,7 @@ class _CommandSetStartPoint:
|
||||
|
||||
class _CommandSetEndPoint:
|
||||
def GetResources(self):
|
||||
return {'Pixmap': 'Path-Holding',
|
||||
return {'Pixmap': 'Path-EndPoint',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Path_Contour", "Pick End Point"),
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Path_Contour", "Pick End Point")}
|
||||
|
||||
@@ -407,7 +347,6 @@ class CommandPathContour:
|
||||
FreeCADGui.doCommand('obj.OffsetExtra = 0.0')
|
||||
FreeCADGui.doCommand('obj.Direction = "CW"')
|
||||
FreeCADGui.doCommand('obj.UseComp = True')
|
||||
FreeCADGui.doCommand('obj.PlungeAngle = 90.0')
|
||||
FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)')
|
||||
|
||||
FreeCADGui.doCommand('PathScripts.PathContour.ObjectContour.setDepths(obj.Proxy, obj)')
|
||||
@@ -420,7 +359,7 @@ class CommandPathContour:
|
||||
class TaskPanel:
|
||||
def __init__(self):
|
||||
self.form = FreeCADGui.PySideUic.loadUi(":/panels/ContourEdit.ui")
|
||||
#self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Path/ContourEdit.ui")
|
||||
# self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Path/ContourEdit.ui")
|
||||
self.updating = False
|
||||
|
||||
def accept(self):
|
||||
@@ -439,23 +378,19 @@ class TaskPanel:
|
||||
def getFields(self):
|
||||
if self.obj:
|
||||
if hasattr(self.obj, "StartDepth"):
|
||||
self.obj.StartDepth = self.form.startDepth.text()
|
||||
self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value
|
||||
if hasattr(self.obj, "FinalDepth"):
|
||||
self.obj.FinalDepth = self.form.finalDepth.text()
|
||||
self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value
|
||||
if hasattr(self.obj, "SafeHeight"):
|
||||
self.obj.SafeHeight = self.form.safeHeight.text()
|
||||
self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value
|
||||
if hasattr(self.obj, "ClearanceHeight"):
|
||||
self.obj.ClearanceHeight = self.form.clearanceHeight.text()
|
||||
self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value
|
||||
if hasattr(self.obj, "StepDown"):
|
||||
self.obj.StepDown = self.form.stepDown.text()
|
||||
self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value
|
||||
if hasattr(self.obj, "OffsetExtra"):
|
||||
self.obj.OffsetExtra = self.form.extraOffset.text()
|
||||
if hasattr(self.obj, "SegLen"):
|
||||
self.obj.SegLen = self.form.segLen.value()
|
||||
self.obj.OffsetExtra = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value
|
||||
if hasattr(self.obj, "RollRadius"):
|
||||
self.obj.RollRadius = self.form.rollRadius.text()
|
||||
if hasattr(self.obj, "PlungeAngle"):
|
||||
self.obj.PlungeAngle = str(self.form.plungeAngle.value())
|
||||
self.obj.RollRadius = FreeCAD.Units.Quantity(self.form.rollRadius.text()).Value
|
||||
if hasattr(self.obj, "UseComp"):
|
||||
self.obj.UseComp = self.form.useCompensation.isChecked()
|
||||
if hasattr(self.obj, "UseStartPoint"):
|
||||
@@ -467,15 +402,13 @@ class TaskPanel:
|
||||
self.obj.Proxy.execute(self.obj)
|
||||
|
||||
def setFields(self):
|
||||
self.form.startDepth.setText(str(self.obj.StartDepth.Value))
|
||||
self.form.finalDepth.setText(str(self.obj.FinalDepth.Value))
|
||||
self.form.safeHeight.setText(str(self.obj.SafeHeight.Value))
|
||||
self.form.clearanceHeight.setText(str(self.obj.ClearanceHeight.Value))
|
||||
self.form.stepDown.setText(str(self.obj.StepDown.Value))
|
||||
self.form.extraOffset.setText(str(self.obj.OffsetExtra.Value))
|
||||
self.form.segLen.setValue(self.obj.SegLen.Value)
|
||||
self.form.rollRadius.setText(str(self.obj.RollRadius.Value))
|
||||
self.form.plungeAngle.setValue(self.obj.PlungeAngle.Value)
|
||||
self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.extraOffset.setText(FreeCAD.Units.Quantity(self.obj.OffsetExtra.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.rollRadius.setText(FreeCAD.Units.Quantity(self.obj.RollRadius.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.useCompensation.setChecked(self.obj.UseComp)
|
||||
self.form.useStartPoint.setChecked(self.obj.UseStartPoint)
|
||||
self.form.useEndPoint.setChecked(self.obj.UseEndPoint)
|
||||
@@ -485,112 +418,14 @@ class TaskPanel:
|
||||
if index >= 0:
|
||||
self.form.direction.setCurrentIndex(index)
|
||||
|
||||
self.form.tagTree.blockSignals(True)
|
||||
for i in range(len(self.obj.locs)):
|
||||
item = QtGui.QTreeWidgetItem(self.form.tagTree)
|
||||
item.setText(0, str(i+1))
|
||||
l = self.obj.locs[i]
|
||||
item.setText(1, str(l.x)+", " + str(l.y) + ", " + str(l.z))
|
||||
item.setText(2, str(self.obj.heights[i]))
|
||||
item.setText(3, str(self.obj.lengths[i]))
|
||||
item.setText(4, str(self.obj.angles[i]))
|
||||
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
|
||||
item.setTextAlignment(0, QtCore.Qt.AlignLeft)
|
||||
self.form.tagTree.blockSignals(False)
|
||||
|
||||
def open(self):
|
||||
self.s = SelObserver()
|
||||
# install the function mode resident
|
||||
FreeCADGui.Selection.addObserver(self.s)
|
||||
|
||||
|
||||
def getStandardButtons(self):
|
||||
return int(QtGui.QDialogButtonBox.Ok)
|
||||
|
||||
def edit(self, item, column):
|
||||
if not self.updating:
|
||||
self.resetObject()
|
||||
|
||||
def resetObject(self, remove=None):
|
||||
"transfers the values from the widget to the object"
|
||||
loc = []
|
||||
h = []
|
||||
l = []
|
||||
a = []
|
||||
|
||||
for i in range(self.form.tagTree.topLevelItemCount()):
|
||||
it = self.form.tagTree.findItems(
|
||||
str(i+1), QtCore.Qt.MatchExactly, 0)[0]
|
||||
if (remove is None) or (remove != i):
|
||||
if it.text(1):
|
||||
x = float(it.text(1).split()[0].rstrip(","))
|
||||
y = float(it.text(1).split()[1].rstrip(","))
|
||||
z = float(it.text(1).split()[2].rstrip(","))
|
||||
loc.append(Vector(x, y, z))
|
||||
|
||||
else:
|
||||
loc.append(0.0)
|
||||
if it.text(2):
|
||||
h.append(float(it.text(2)))
|
||||
else:
|
||||
h.append(4.0)
|
||||
if it.text(3):
|
||||
l.append(float(it.text(3)))
|
||||
else:
|
||||
l.append(5.0)
|
||||
if it.text(4):
|
||||
a.append(float(it.text(4)))
|
||||
else:
|
||||
a.append(45.0)
|
||||
|
||||
self.obj.locs = loc
|
||||
self.obj.heights = h
|
||||
self.obj.lengths = l
|
||||
self.obj.angles = a
|
||||
|
||||
self.obj.touch()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
def addElement(self):
|
||||
self.updating = True
|
||||
|
||||
item = QtGui.QTreeWidgetItem(self.form.tagTree)
|
||||
item.setText(0, str(self.form.tagTree.topLevelItemCount()))
|
||||
item.setText(1, "0.0, 0.0, 0.0")
|
||||
item.setText(2, str(float(4.0)))
|
||||
item.setText(3, str(float(10.0)))
|
||||
item.setText(4, str(float(45.0)))
|
||||
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
|
||||
self.updating = False
|
||||
|
||||
self.resetObject()
|
||||
|
||||
def removeElement(self):
|
||||
it = self.form.tagTree.currentItem()
|
||||
if it:
|
||||
nr = int(it.text(0))-1
|
||||
self.resetObject(remove=nr)
|
||||
self.update()
|
||||
|
||||
def update(self):
|
||||
'fills the treewidget'
|
||||
self.updating = True
|
||||
self.form.tagTree.clear()
|
||||
if self.obj:
|
||||
for i in range(len(self.obj.locs)):
|
||||
item = QtGui.QTreeWidgetItem(self.form.tagTree)
|
||||
item.setText(0, str(i+1))
|
||||
l = self.obj.locs[i]
|
||||
item.setText(1, str(l.x) + ", " + str(l.y) + ", " + str(l.z))
|
||||
item.setText(2, str(self.obj.heights[i]))
|
||||
item.setText(3, str(self.obj.lengths[i]))
|
||||
item.setText(4, str(self.obj.angles[i]))
|
||||
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
|
||||
item.setTextAlignment(0, QtCore.Qt.AlignLeft)
|
||||
self.updating = False
|
||||
return
|
||||
|
||||
|
||||
def setupUi(self):
|
||||
|
||||
# Connect Signals and Slots
|
||||
@@ -609,17 +444,8 @@ class TaskPanel:
|
||||
self.form.useStartPoint.clicked.connect(self.getFields)
|
||||
self.form.useEndPoint.clicked.connect(self.getFields)
|
||||
self.form.extraOffset.editingFinished.connect(self.getFields)
|
||||
self.form.segLen.editingFinished.connect(self.getFields)
|
||||
self.form.rollRadius.editingFinished.connect(self.getFields)
|
||||
|
||||
# Tag Form
|
||||
QtCore.QObject.connect(
|
||||
self.form.tagTree,
|
||||
QtCore.SIGNAL("itemChanged(QTreeWidgetItem *, int)"),
|
||||
self.edit)
|
||||
self.form.addTag.clicked.connect(self.addElement)
|
||||
self.form.deleteTag.clicked.connect(self.removeElement)
|
||||
|
||||
self.setFields()
|
||||
|
||||
|
||||
@@ -640,7 +466,6 @@ class SelObserver:
|
||||
if FreeCAD.GuiUp:
|
||||
# register the FreeCAD command
|
||||
FreeCADGui.addCommand('Path_Contour', CommandPathContour())
|
||||
FreeCADGui.addCommand('Add_Tag', _CommandAddTag())
|
||||
FreeCADGui.addCommand('Set_StartPoint', _CommandSetStartPoint())
|
||||
FreeCADGui.addCommand('Set_EndPoint', _CommandSetEndPoint())
|
||||
|
||||
|
||||
@@ -275,7 +275,7 @@ class Chord (object):
|
||||
return dir == 'Back' or dir == side
|
||||
|
||||
def connectsTo(self, chord):
|
||||
return PathGeom.isRoughly(self.End, chord.Start)
|
||||
return PathGeom.pointsCoincide(self.End, chord.Start)
|
||||
|
||||
class Bone:
|
||||
def __init__(self, boneId, obj, lastCommand, inChord, outChord, smooth):
|
||||
|
||||
1415
src/Mod/Path/PathScripts/PathDressupHoldingTags.py
Normal file
1415
src/Mod/Path/PathScripts/PathDressupHoldingTags.py
Normal file
File diff suppressed because it is too large
Load Diff
@@ -400,27 +400,27 @@ class TaskPanel:
|
||||
def getFields(self):
|
||||
if self.obj:
|
||||
if hasattr(self.obj, "StartDepth"):
|
||||
self.obj.StartDepth = self.form.startDepth.text()
|
||||
self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value
|
||||
if hasattr(self.obj, "FinalDepth"):
|
||||
self.obj.FinalDepth = self.form.finalDepth.text()
|
||||
self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value
|
||||
if hasattr(self.obj, "PeckDepth"):
|
||||
self.obj.PeckDepth = self.form.peckDepth.text()
|
||||
self.obj.PeckDepth = FreeCAD.Units.Quantity(self.form.peckDepth.text()).Value
|
||||
if hasattr(self.obj, "SafeHeight"):
|
||||
self.obj.SafeHeight = self.form.safeHeight.text()
|
||||
self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value
|
||||
if hasattr(self.obj, "ClearanceHeight"):
|
||||
self.obj.ClearanceHeight = self.form.clearanceHeight.text()
|
||||
self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value
|
||||
if hasattr(self.obj, "RetractHeight"):
|
||||
self.obj.RetractHeight = self.form.retractHeight.text()
|
||||
self.obj.RetractHeight = FreeCAD.Units.Quantity(self.form.retractHeight.text()).Value
|
||||
|
||||
self.obj.Proxy.execute(self.obj)
|
||||
|
||||
def setFields(self):
|
||||
self.form.startDepth.setText(str(self.obj.StartDepth.Value))
|
||||
self.form.finalDepth.setText(str(self.obj.FinalDepth.Value))
|
||||
self.form.peckDepth.setText(str(self.obj.PeckDepth.Value))
|
||||
self.form.safeHeight.setText(str(self.obj.SafeHeight.Value))
|
||||
self.form.clearanceHeight.setText(str(self.obj.ClearanceHeight.Value))
|
||||
self.form.retractHeight.setText(str(self.obj.RetractHeight.Value))
|
||||
self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.peckDepth.setText(FreeCAD.Units.Quantity(self.obj.PeckDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.retractHeight.setText(FreeCAD.Units.Quantity(self.obj.RetractHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
|
||||
self.form.baseList.clear()
|
||||
for i in self.obj.Base:
|
||||
|
||||
@@ -320,18 +320,18 @@ class TaskPanel:
|
||||
def getFields(self):
|
||||
if self.obj:
|
||||
if hasattr(self.obj, "FinalDepth"):
|
||||
self.obj.FinalDepth = self.form.finalDepth.text()
|
||||
self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value
|
||||
if hasattr(self.obj, "SafeHeight"):
|
||||
self.obj.SafeHeight = self.form.safeHeight.text()
|
||||
self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value
|
||||
if hasattr(self.obj, "ClearanceHeight"):
|
||||
self.obj.ClearanceHeight = self.form.clearanceHeight.text()
|
||||
self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value
|
||||
|
||||
self.obj.Proxy.execute(self.obj)
|
||||
|
||||
def setFields(self):
|
||||
self.form.finalDepth.setText(str(self.obj.FinalDepth.Value))
|
||||
self.form.safeHeight.setText(str(self.obj.SafeHeight.Value))
|
||||
self.form.clearanceHeight.setText(str(self.obj.ClearanceHeight.Value))
|
||||
self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
|
||||
self.form.baseList.clear()
|
||||
for i in self.obj.Base:
|
||||
|
||||
@@ -29,6 +29,8 @@ import Path
|
||||
|
||||
from FreeCAD import Vector
|
||||
|
||||
PathGeomTolerance = 0.000001
|
||||
|
||||
class Side:
|
||||
"""Class to determine and define the side a Path is on, or Vectors are in relation to each other."""
|
||||
Left = +1
|
||||
@@ -63,39 +65,53 @@ class Side:
|
||||
class PathGeom:
|
||||
"""Class to transform Path Commands into Edges and Wire and back again.
|
||||
The interface might eventuallly become part of Path itself."""
|
||||
CmdMoveFast = ['G0', 'G00']
|
||||
CmdMoveRapid = ['G0', 'G00']
|
||||
CmdMoveStraight = ['G1', 'G01']
|
||||
CmdMoveCW = ['G2', 'G02']
|
||||
CmdMoveCCW = ['G3', 'G03']
|
||||
CmdMoveArc = CmdMoveCW + CmdMoveCCW
|
||||
CmdMove = CmdMoveStraight + CmdMoveArc
|
||||
|
||||
Tolerance = PathGeomTolerance
|
||||
|
||||
@classmethod
|
||||
def isRoughly(cls, float1, float2, error=0.0000001):
|
||||
"""(float1, float2, [error=0.0000001])
|
||||
Returns true if the two values are the same within a given error."""
|
||||
def isRoughly(cls, float1, float2, error=PathGeomTolerance):
|
||||
"""(float1, float2, [error=%s])
|
||||
Returns true if the two values are the same within a given error.""" % PathGeomTolerance
|
||||
return math.fabs(float1 - float2) <= error
|
||||
|
||||
@classmethod
|
||||
def pointsCoincide(cls, p1, p2, error=0.0000001):
|
||||
"""(p1, p2, [error=0.0000001])
|
||||
Return True if two points are roughly identical (see also isRoughly)."""
|
||||
def pointsCoincide(cls, p1, p2, error=PathGeomTolerance):
|
||||
"""(p1, p2, [error=%s])
|
||||
Return True if two points are roughly identical (see also isRoughly).""" % PathGeomTolerance
|
||||
return cls.isRoughly(p1.x, p2.x, error) and cls.isRoughly(p1.y, p2.y, error) and cls.isRoughly(p1.z, p2.z, error)
|
||||
|
||||
@classmethod
|
||||
def edgeConnectsTo(cls, edge, vector):
|
||||
"""(edge, vector)
|
||||
Returns True if edge connects to given vector."""
|
||||
def edgesMatch(cls, e0, e1, error=PathGeomTolerance):
|
||||
"""(e0, e1, [error=%s]
|
||||
Return true if the edges start and end at the same point and have the same type of curve.""" % PathGeomTolerance
|
||||
if type(e0.Curve) != type(e1.Curve):
|
||||
return False
|
||||
if not cls.pointsCoincide(e0.valueAt(e0.FirstParameter), e1.valueAt(e1.FirstParameter)):
|
||||
return False
|
||||
if not cls.pointsCoincide(e0.valueAt(e0.LastParameter), e1.valueAt(e1.LastParameter)):
|
||||
return False
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def edgeConnectsTo(cls, edge, vector, error=PathGeomTolerance):
|
||||
"""(edge, vector, error=%f)
|
||||
Returns True if edge connects to given vector.""" % PathGeomTolerance
|
||||
return cls.pointsCoincide(edge.valueAt(edge.FirstParameter), vector) or cls.pointsCoincide(edge.valueAt(edge.LastParameter), vector)
|
||||
|
||||
@classmethod
|
||||
def getAngle(cls, vertex):
|
||||
"""(vertex)
|
||||
Returns the angle [-pi,pi] of a vertex using the X-axis as the reference.
|
||||
def getAngle(cls, vector):
|
||||
"""(vector)
|
||||
Returns the angle [-pi,pi] of a vector using the X-axis as the reference.
|
||||
Positive angles for vertexes in the upper hemishpere (positive y values)
|
||||
and negative angles for the lower hemishpere."""
|
||||
a = vertex.getAngle(FreeCAD.Vector(1,0,0))
|
||||
if vertex.y < 0:
|
||||
a = vector.getAngle(Vector(1,0,0))
|
||||
if vector.y < 0:
|
||||
return -a
|
||||
return a
|
||||
|
||||
@@ -120,7 +136,7 @@ class PathGeom:
|
||||
x = cmd.Parameters.get(X, defaultPoint.x)
|
||||
y = cmd.Parameters.get(Y, defaultPoint.y)
|
||||
z = cmd.Parameters.get(Z, defaultPoint.z)
|
||||
return FreeCAD.Vector(x, y, z)
|
||||
return Vector(x, y, z)
|
||||
|
||||
@classmethod
|
||||
def xy(cls, point):
|
||||
@@ -128,13 +144,76 @@ class PathGeom:
|
||||
Convenience function to return the projection of the Vector in the XY-plane."""
|
||||
return Vector(point.x, point.y, 0)
|
||||
|
||||
@classmethod
|
||||
def cmdsForEdge(cls, edge, flip = False, useHelixForBSpline = True, segm = 50):
|
||||
"""(edge, flip=False, useHelixForBSpline=True, segm=50) -> List(Path.Command)
|
||||
Returns a list of Path.Command representing the given edge.
|
||||
If flip is True the edge is considered to be backwards.
|
||||
If useHelixForBSpline is True an Edge based on a BSplineCurve is considered
|
||||
to represent a helix and results in G2 or G3 command. Otherwise edge has
|
||||
no direct Path.Command mapping and will be approximated by straight segments.
|
||||
segm is a factor for the segmentation of arbitrary curves not mapped to G1/2/3
|
||||
commands. The higher the value the more segments will be used."""
|
||||
pt = edge.valueAt(edge.LastParameter) if not flip else edge.valueAt(edge.FirstParameter)
|
||||
params = {'X': pt.x, 'Y': pt.y, 'Z': pt.z}
|
||||
if type(edge.Curve) == Part.Line or type(edge.Curve) == Part.LineSegment:
|
||||
commands = [Path.Command('G1', params)]
|
||||
else:
|
||||
if not flip:
|
||||
p1 = edge.valueAt(edge.FirstParameter)
|
||||
p3 = pt
|
||||
else:
|
||||
p1 = pt
|
||||
p3 = edge.valueAt(edge.LastParameter)
|
||||
p2 = edge.valueAt((edge.FirstParameter + edge.LastParameter)/2)
|
||||
if (type(edge.Curve) == Part.Circle and cls.isRoughly(edge.Curve.Axis.x, 0) and cls.isRoughly(edge.Curve.Axis.y, 0)) or (useHelixForBSpline and type(edge.Curve) == Part.BSplineCurve):
|
||||
if Side.Left == Side.of(p2 - p1, p3 - p2):
|
||||
cmd = 'G3'
|
||||
else:
|
||||
cmd = 'G2'
|
||||
#print("**** (%.2f, %.2f, %.2f) - (%.2f, %.2f, %.2f) - (%.2f, %.2f, %.2f)" % (p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, p3.x, p3.y, p3.z))
|
||||
pd = Part.Circle(PathGeom.xy(p1), PathGeom.xy(p2), PathGeom.xy(p3)).Center
|
||||
|
||||
pa = PathGeom.xy(p1)
|
||||
pb = PathGeom.xy(p2)
|
||||
pc = PathGeom.xy(p3)
|
||||
#print("**** (%.2f, %.2f, %.2f) - (%.2f, %.2f, %.2f)" % (pa.x, pa.y, pa.z, pc.x, pc.y, pc.z))
|
||||
#print("**** (%.2f, %.2f, %.2f) - (%.2f, %.2f, %.2f)" % (pb.x, pb.y, pb.z, pd.x, pd.y, pd.z))
|
||||
offset = Part.Circle(PathGeom.xy(p1), PathGeom.xy(p2), PathGeom.xy(p3)).Center - p1
|
||||
#print("**** (%.2f, %.2f, %.2f)" % (offset.x, offset.y, offset.z))
|
||||
params.update({'I': offset.x, 'J': offset.y, 'K': (p3.z - p1.z)/2})
|
||||
commands = [ Path.Command(cmd, params) ]
|
||||
else:
|
||||
eStraight = Part.Edge(Part.LineSegment(p1, p3))
|
||||
esP2 = eStraight.valueAt((eStraight.FirstParameter + eStraight.LastParameter)/2)
|
||||
deviation = (p2 - esP2).Length
|
||||
if cls.isRoughly(deviation, 0):
|
||||
return [ Path.Command('G1', {'X': p3.x, 'Y': p3.y, 'Z': p3.z}) ]
|
||||
# at this point pixellation is all we can do
|
||||
commands = []
|
||||
segments = int(math.ceil((deviation / eStraight.Length) * segm))
|
||||
#print("**** pixellation with %d segments" % segments)
|
||||
dParameter = (edge.LastParameter - edge.FirstParameter) / segments
|
||||
for i in range(0, segments):
|
||||
if flip:
|
||||
p = edge.valueAt(edge.LastParameter - (i + 1) * dParameter)
|
||||
else:
|
||||
p = edge.valueAt(edge.FirstParameter + (i + 1) * dParameter)
|
||||
cmd = Path.Command('G1', {'X': p.x, 'Y': p.y, 'Z': p.z})
|
||||
#print("***** %s" % cmd)
|
||||
commands.append(cmd)
|
||||
#print commands
|
||||
return commands
|
||||
|
||||
@classmethod
|
||||
def edgeForCmd(cls, cmd, startPoint):
|
||||
"""(cmd, startPoint).
|
||||
Returns an Edge representing the given command, assuming a given startPoint."""
|
||||
|
||||
endPoint = cls.commandEndPoint(cmd, startPoint)
|
||||
if (cmd.Name in cls.CmdMoveStraight) or (cmd.Name in cls.CmdMoveFast):
|
||||
if (cmd.Name in cls.CmdMoveStraight) or (cmd.Name in cls.CmdMoveRapid):
|
||||
if cls.pointsCoincide(startPoint, endPoint):
|
||||
return None
|
||||
return Part.Edge(Part.LineSegment(startPoint, endPoint))
|
||||
|
||||
if cmd.Name in cls.CmdMoveArc:
|
||||
@@ -157,7 +236,7 @@ class PathGeom:
|
||||
#print("arc: A=(%.2f, %.2f) B=(%.2f, %.2f) -> d=%.2f" % (A.x, A.y, B.x, B.y, d))
|
||||
#print("arc: R=%.2f angle=%.2f" % (R, angle/math.pi))
|
||||
if startPoint.z == endPoint.z:
|
||||
midPoint = center + FreeCAD.Vector(math.cos(angle), math.sin(angle), 0) * R
|
||||
midPoint = center + Vector(math.cos(angle), math.sin(angle), 0) * R
|
||||
return Part.Edge(Part.Arc(startPoint, midPoint, endPoint))
|
||||
|
||||
# It's a Helix
|
||||
@@ -180,20 +259,23 @@ class PathGeom:
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def wireForPath(cls, path, startPoint = FreeCAD.Vector(0, 0, 0)):
|
||||
def wireForPath(cls, path, startPoint = Vector(0, 0, 0)):
|
||||
"""(path, [startPoint=Vector(0,0,0)])
|
||||
Returns a wire representing all move commands found in the given path."""
|
||||
edges = []
|
||||
rapid = []
|
||||
if hasattr(path, "Commands"):
|
||||
for cmd in path.Commands:
|
||||
edge = cls.edgeForCmd(cmd, startPoint)
|
||||
if edge:
|
||||
if cmd.Name in cls.CmdMoveRapid:
|
||||
rapid.append(edge)
|
||||
edges.append(edge)
|
||||
startPoint = cls.commandEndPoint(cmd, startPoint)
|
||||
return Part.Wire(edges)
|
||||
return (Part.Wire(edges), rapid)
|
||||
|
||||
@classmethod
|
||||
def wiresForPath(cls, path, startPoint = FreeCAD.Vector(0, 0, 0)):
|
||||
def wiresForPath(cls, path, startPoint = Vector(0, 0, 0)):
|
||||
"""(path, [startPoint=Vector(0,0,0)])
|
||||
Returns a collection of wires, each representing a continuous cutting Path in path."""
|
||||
wires = []
|
||||
@@ -203,7 +285,7 @@ class PathGeom:
|
||||
if cmd.Name in cls.CmdMove:
|
||||
edges.append(cls.edgeForCmd(cmd, startPoint))
|
||||
startPoint = cls.commandEndPoint(cmd, startPoint)
|
||||
elif cmd.Name in cls.CmdMoveFast:
|
||||
elif cmd.Name in cls.CmdMoveRapid:
|
||||
wires.append(Part.Wire(edges))
|
||||
edges = []
|
||||
startPoint = cls.commandEndPoint(cmd, startPoint)
|
||||
@@ -211,3 +293,81 @@ class PathGeom:
|
||||
wires.append(Part.Wire(edges))
|
||||
return wires
|
||||
|
||||
@classmethod
|
||||
def arcToHelix(cls, edge, z0, z1):
|
||||
"""(edge, z0, z1)
|
||||
Assuming edge is an arc it'll return a helix matching the arc starting at z0 and rising/falling to z1."""
|
||||
|
||||
|
||||
p1 = edge.valueAt(edge.FirstParameter)
|
||||
p2 = edge.valueAt(edge.LastParameter)
|
||||
|
||||
cmd = cls.cmdsForEdge(edge)[0]
|
||||
params = cmd.Parameters
|
||||
params.update({'Z': z1, 'K': (z1 - z0)/2})
|
||||
command = Path.Command(cmd.Name, params)
|
||||
|
||||
#print("- (%.2f, %.2f, %.2f) - (%.2f, %.2f, %.2f): %.2f:%.2f" % (edge.Vertexes[0].X, edge.Vertexes[0].Y, edge.Vertexes[0].Z, edge.Vertexes[1].X, edge.Vertexes[1].Y, edge.Vertexes[1].Z, z0, z1))
|
||||
#print("- %s -> %s" % (cmd, command))
|
||||
|
||||
return cls.edgeForCmd(command, Vector(p1.x, p1.y, z0))
|
||||
|
||||
|
||||
@classmethod
|
||||
def helixToArc(cls, edge, z = 0):
|
||||
"""(edge, z=0)
|
||||
Returns the projection of the helix onto the XY-plane with a given offset."""
|
||||
p1 = edge.valueAt(edge.FirstParameter)
|
||||
p2 = edge.valueAt((edge.FirstParameter + edge.LastParameter)/2)
|
||||
p3 = edge.valueAt(edge.LastParameter)
|
||||
p01 = Vector(p1.x, p1.y, z)
|
||||
p02 = Vector(p2.x, p2.y, z)
|
||||
p03 = Vector(p3.x, p3.y, z)
|
||||
return Part.Edge(Part.Arc(p01, p02, p03))
|
||||
|
||||
@classmethod
|
||||
def splitArcAt(cls, edge, pt):
|
||||
"""(edge, pt)
|
||||
Returns a list of 2 edges which together form the original arc split at the given point.
|
||||
The Vector pt has to represnt a point on the given arc."""
|
||||
p1 = edge.valueAt(edge.FirstParameter)
|
||||
p2 = pt
|
||||
p3 = edge.valueAt(edge.LastParameter)
|
||||
edges = []
|
||||
|
||||
p = edge.Curve.parameter(p2)
|
||||
#print("splitArcAt(%.2f, %.2f, %.2f): %.2f - %.2f - %.2f" % (pt.x, pt.y, pt.z, edge.FirstParameter, p, edge.LastParameter))
|
||||
|
||||
p12 = edge.Curve.value((edge.FirstParameter + p)/2)
|
||||
p23 = edge.Curve.value((p + edge.LastParameter)/2)
|
||||
#print("splitArcAt: p12=(%.2f, %.2f, %.2f) p23=(%.2f, %.2f, %.2f)" % (p12.x, p12.y, p12.z, p23.x, p23.y, p23.z))
|
||||
|
||||
edges.append(Part.Edge(Part.Arc(p1, p12, p2)))
|
||||
edges.append(Part.Edge(Part.Arc(p2, p23, p3)))
|
||||
|
||||
return edges
|
||||
|
||||
@classmethod
|
||||
def splitEdgeAt(cls, edge, pt):
|
||||
"""(edge, pt)
|
||||
Returns a list of 2 edges, forming the original edge split at the given point.
|
||||
The results are undefined if the Vector representing the point is not part of the edge."""
|
||||
# I could not get the OCC parameterAt and split to work ...
|
||||
# pt HAS to be on the edge, otherwise the results are undefined
|
||||
p1 = edge.valueAt(edge.FirstParameter)
|
||||
p2 = pt
|
||||
p3 = edge.valueAt(edge.LastParameter)
|
||||
edges = []
|
||||
|
||||
if type(edge.Curve) == Part.Line or type(edge.Curve) == Part.LineSegment:
|
||||
# it's a line
|
||||
return [Part.Edge(Part.LineSegment(p1, p2)), Part.Edge(Part.LineSegment(p2, p3))]
|
||||
elif type(edge.Curve) == Part.Circle:
|
||||
# it's an arc
|
||||
return cls.splitArcAt(edge, pt)
|
||||
else:
|
||||
# it's a helix
|
||||
arc = cls.helixToArc(edge, 0)
|
||||
aes = cls.splitArcAt(arc, Vector(pt.x, pt.y, 0))
|
||||
return [cls.arcToHelix(aes[0], p1.z, p2.z), cls.arcToHelix(aes[1], p2.z, p3.z)]
|
||||
|
||||
|
||||
@@ -420,19 +420,20 @@ class TaskPanel:
|
||||
def getFields(self):
|
||||
if self.obj:
|
||||
if hasattr(self.obj, "StartDepth"):
|
||||
self.obj.StartDepth = self.form.startDepth.text()
|
||||
self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value
|
||||
if hasattr(self.obj, "FinalDepth"):
|
||||
self.obj.FinalDepth = self.form.finalDepth.text()
|
||||
self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value
|
||||
if hasattr(self.obj, "FinishDepth"):
|
||||
self.obj.FinishDepth = self.form.finishDepth.text()
|
||||
self.obj.FinishDepth = FreeCAD.Units.Quantity(self.form.finishDepth.text()).Value
|
||||
if hasattr(self.obj, "SafeHeight"):
|
||||
self.obj.SafeHeight = self.form.safeHeight.text()
|
||||
self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value
|
||||
if hasattr(self.obj, "ClearanceHeight"):
|
||||
self.obj.ClearanceHeight = self.form.clearanceHeight.text()
|
||||
self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value
|
||||
if hasattr(self.obj, "StepDown"):
|
||||
self.obj.StepDown = self.form.stepDown.value()
|
||||
self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value
|
||||
if hasattr(self.obj, "PassExtension"):
|
||||
self.obj.PassExtension = self.form.extraOffset.value()
|
||||
self.obj.PassExtension = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value
|
||||
|
||||
# if hasattr(self.obj, "UseStartPoint"):
|
||||
# self.obj.UseStartPoint = self.form.useStartPoint.isChecked()
|
||||
if hasattr(self.obj, "CutMode"):
|
||||
@@ -442,7 +443,9 @@ class TaskPanel:
|
||||
if hasattr(self.obj, "ZigUnidirectional"):
|
||||
self.obj.ZigUnidirectional = self.form.zigZagUnidirectional.isChecked()
|
||||
if hasattr(self.obj, "ZigZagAngle"):
|
||||
self.obj.ZigZagAngle = self.form.zigZagAngle.value()
|
||||
self.obj.ZigZagAngle = FreeCAD.Units.Quantity(self.form.zigZagAngle.text()).Value
|
||||
# if hasattr(self.obj, "ZigZagAngle"):
|
||||
# self.obj.ZigZagAngle = self.form.zigZagAngle.value()
|
||||
if hasattr(self.obj, "StepOver"):
|
||||
self.obj.StepOver = self.form.stepOverPercent.value()
|
||||
if hasattr(self.obj, "BoundaryShape"):
|
||||
@@ -451,16 +454,18 @@ class TaskPanel:
|
||||
self.obj.Proxy.execute(self.obj)
|
||||
|
||||
def setFields(self):
|
||||
self.form.startDepth.setText(str(self.obj.StartDepth.Value))
|
||||
self.form.finalDepth.setText(str(self.obj.FinalDepth.Value))
|
||||
self.form.finishDepth.setText(str(self.obj.FinishDepth.Value))
|
||||
self.form.stepDown.setValue(self.obj.StepDown)
|
||||
self.form.safeHeight.setText(str(self.obj.SafeHeight.Value))
|
||||
self.form.clearanceHeight.setText(str(self.obj.ClearanceHeight.Value))
|
||||
self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.finishDepth.setText(FreeCAD.Units.Quantity(self.obj.FinishDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown, FreeCAD.Units.Length).UserString)
|
||||
self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
|
||||
self.form.stepOverPercent.setValue(self.obj.StepOver)
|
||||
self.form.useZigZag.setChecked(self.obj.UseZigZag)
|
||||
self.form.zigZagUnidirectional.setChecked(self.obj.ZigUnidirectional)
|
||||
self.form.zigZagAngle.setValue(self.obj.ZigZagAngle)
|
||||
self.form.zigZagAngle.setValue(FreeCAD.Units.Quantity(self.obj.ZigZagAngle, FreeCAD.Units.Angle))
|
||||
# self.form.zigZagAngle.setValue(self.obj.ZigZagAngle)
|
||||
#self.form.useStartPoint.setChecked(self.obj.UseStartPoint)
|
||||
self.form.extraOffset.setValue(self.obj.PassExtension.Value)
|
||||
|
||||
|
||||
@@ -338,7 +338,7 @@ class ObjectPocket:
|
||||
else:
|
||||
output += "G3"
|
||||
output += " X" + fmt(point.x) + " Y" + fmt(point.y) + " Z" + fmt(vpos)
|
||||
output += " I" + fmt(relcenter.x) + " J" + fmt(relcenter.y) + " K" + fmt(relcenter.z) + " F" + fmt(self.horizFeed)
|
||||
output += " I" + fmt(relcenter.x) + " J" + fmt(relcenter.y) + " K" + fmt(relcenter.z) + " F" + fmt(self.horizFeed)
|
||||
output += "\n"
|
||||
last = point
|
||||
else:
|
||||
@@ -545,17 +545,17 @@ class TaskPanel:
|
||||
def getFields(self):
|
||||
if self.obj:
|
||||
if hasattr(self.obj, "StartDepth"):
|
||||
self.obj.StartDepth = self.form.startDepth.text()
|
||||
self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value
|
||||
if hasattr(self.obj, "FinalDepth"):
|
||||
self.obj.FinalDepth = self.form.finalDepth.text()
|
||||
self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value
|
||||
if hasattr(self.obj, "SafeHeight"):
|
||||
self.obj.SafeHeight = self.form.safeHeight.text()
|
||||
self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value
|
||||
if hasattr(self.obj, "ClearanceHeight"):
|
||||
self.obj.ClearanceHeight = self.form.clearanceHeight.text()
|
||||
self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value
|
||||
if hasattr(self.obj, "StepDown"):
|
||||
self.obj.StepDown = self.form.stepDown.text()
|
||||
self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value
|
||||
if hasattr(self.obj, "MaterialAllowance"):
|
||||
self.obj.MaterialAllowance = self.form.extraOffset.text()
|
||||
self.obj.MaterialAllowance = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value
|
||||
if hasattr(self.obj, "UseStartPoint"):
|
||||
self.obj.UseStartPoint = self.form.useStartPoint.isChecked()
|
||||
if hasattr(self.obj, "Algorithm"):
|
||||
@@ -567,23 +567,23 @@ class TaskPanel:
|
||||
if hasattr(self.obj, "ZigUnidirectional"):
|
||||
self.obj.ZigUnidirectional = self.form.zigZagUnidirectional.isChecked()
|
||||
if hasattr(self.obj, "ZigZagAngle"):
|
||||
self.obj.ZigZagAngle = self.form.zigZagAngle.value()
|
||||
self.obj.ZigZagAngle = FreeCAD.Units.Quantity(self.form.zigZagAngle.text()).Value
|
||||
if hasattr(self.obj, "StepOver"):
|
||||
self.obj.StepOver = self.form.stepOverPercent.value()
|
||||
|
||||
self.obj.Proxy.execute(self.obj)
|
||||
|
||||
def setFields(self):
|
||||
self.form.startDepth.setText(str(self.obj.StartDepth.Value))
|
||||
self.form.finalDepth.setText(str(self.obj.FinalDepth.Value))
|
||||
self.form.safeHeight.setText(str(self.obj.SafeHeight.Value))
|
||||
self.form.clearanceHeight.setText(str(self.obj.ClearanceHeight.Value))
|
||||
self.form.stepDown.setText(str(self.obj.StepDown))
|
||||
self.form.extraOffset.setText(str(self.obj.MaterialAllowance.Value))
|
||||
self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.extraOffset.setText(FreeCAD.Units.Quantity(self.obj.MaterialAllowance, FreeCAD.Units.Length).UserString)
|
||||
self.form.useStartPoint.setChecked(self.obj.UseStartPoint)
|
||||
self.form.useZigZag.setChecked(self.obj.UseZigZag)
|
||||
self.form.zigZagUnidirectional.setChecked(self.obj.ZigUnidirectional)
|
||||
self.form.zigZagAngle.setValue(self.obj.ZigZagAngle)
|
||||
self.form.zigZagAngle.setText(FreeCAD.Units.Quantity(self.obj.ZigZagAngle, FreeCAD.Units.Angle).UserString)
|
||||
self.form.stepOverPercent.setValue(self.obj.StepOver)
|
||||
|
||||
index = self.form.algorithmSelect.findText(self.obj.Algorithm, QtCore.Qt.MatchFixedString)
|
||||
|
||||
@@ -31,6 +31,10 @@ class PathPreferences:
|
||||
PostProcessorDefaultArgs = "PostProcessorDefaultArgs"
|
||||
PostProcessorBlacklist = "PostProcessorBlacklist"
|
||||
|
||||
@classmethod
|
||||
def preferences(cls):
|
||||
return FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
|
||||
|
||||
@classmethod
|
||||
def allAvailablePostProcessors(cls):
|
||||
path = FreeCAD.getHomePath() + ("Mod/Path/PathScripts/")
|
||||
@@ -58,28 +62,28 @@ class PathPreferences:
|
||||
|
||||
@classmethod
|
||||
def defaultPostProcessor(cls):
|
||||
preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
|
||||
return preferences.GetString(cls.PostProcessorDefault, "")
|
||||
pref = cls.preferences()
|
||||
return pref.GetString(cls.PostProcessorDefault, "")
|
||||
|
||||
@classmethod
|
||||
def defaultPostProcessorArgs(cls):
|
||||
preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
|
||||
return preferences.GetString(cls.PostProcessorDefaultArgs, "")
|
||||
pref = cls.preferences()
|
||||
return pref.GetString(cls.PostProcessorDefaultArgs, "")
|
||||
|
||||
@classmethod
|
||||
def postProcessorBlacklist(cls):
|
||||
preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
|
||||
blacklist = preferences.GetString(cls.PostProcessorBlacklist, "")
|
||||
pref = cls.preferences()
|
||||
blacklist = pref.GetString(cls.PostProcessorBlacklist, "")
|
||||
if not blacklist:
|
||||
return []
|
||||
return eval(blacklist)
|
||||
|
||||
@classmethod
|
||||
def savePostProcessorDefaults(cls, processor, args, blacklist):
|
||||
preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
|
||||
preferences.SetString(cls.PostProcessorDefault, processor)
|
||||
preferences.SetString(cls.PostProcessorDefaultArgs, args)
|
||||
preferences.SetString(cls.PostProcessorBlacklist, "%s" % (blacklist))
|
||||
pref = cls.preferences()
|
||||
pref.SetString(cls.PostProcessorDefault, processor)
|
||||
pref.SetString(cls.PostProcessorDefaultArgs, args)
|
||||
pref.SetString(cls.PostProcessorBlacklist, "%s" % (blacklist))
|
||||
|
||||
|
||||
DefaultOutputFile = "DefaultOutputFile"
|
||||
@@ -87,16 +91,16 @@ class PathPreferences:
|
||||
|
||||
@classmethod
|
||||
def saveOutputFileDefaults(cls, file, policy):
|
||||
preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
|
||||
preferences.SetString(cls.DefaultOutputFile, file)
|
||||
preferences.SetString(cls.DefaultOutputPolicy, policy)
|
||||
pref = cls.preferences()
|
||||
pref.SetString(cls.DefaultOutputFile, file)
|
||||
pref.SetString(cls.DefaultOutputPolicy, policy)
|
||||
|
||||
@classmethod
|
||||
def defaultOutputFile(cls):
|
||||
preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
|
||||
return preferences.GetString(cls.DefaultOutputFile, "")
|
||||
pref = cls.preferences()
|
||||
return pref.GetString(cls.DefaultOutputFile, "")
|
||||
|
||||
@classmethod
|
||||
def defaultOutputPolicy(cls):
|
||||
preferences = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
|
||||
return preferences.GetString(cls.DefaultOutputPolicy, "")
|
||||
pref = cls.preferences()
|
||||
return pref.GetString(cls.DefaultOutputPolicy, "")
|
||||
|
||||
68
src/Mod/Path/PathScripts/PathPreferencesPathDressup.py
Normal file
68
src/Mod/Path/PathScripts/PathPreferencesPathDressup.py
Normal file
@@ -0,0 +1,68 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
# * Copyright (c) 2016 sliptonic <shopinthewoods@gmail.com> *
|
||||
# * *
|
||||
# * This program is free software; you can redistribute it and/or modify *
|
||||
# * it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
# * as published by the Free Software Foundation; either version 2 of *
|
||||
# * the License, or (at your option) any later version. *
|
||||
# * for detail see the LICENCE text file. *
|
||||
# * *
|
||||
# * This program is distributed in the hope that it will be useful, *
|
||||
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
# * GNU Library General Public License for more details. *
|
||||
# * *
|
||||
# * You should have received a copy of the GNU Library General Public *
|
||||
# * License along with this program; if not, write to the Free Software *
|
||||
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||
# * USA *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
from PySide import QtCore, QtGui
|
||||
from PathScripts.PathPreferences import PathPreferences
|
||||
|
||||
# Qt tanslation handling
|
||||
try:
|
||||
_encoding = QtGui.QApplication.UnicodeUTF8
|
||||
|
||||
def translate(context, text, disambig=None):
|
||||
return QtGui.QApplication.translate(context, text, disambig, _encoding)
|
||||
|
||||
except AttributeError:
|
||||
|
||||
def translate(context, text, disambig=None):
|
||||
return QtGui.QApplication.translate(context, text, disambig)
|
||||
|
||||
_dressups = []
|
||||
|
||||
def RegisterDressup(dressup):
|
||||
_dressups.append(dressup)
|
||||
|
||||
class DressupPreferencesPage:
|
||||
def __init__(self, parent=None):
|
||||
self.form = QtGui.QToolBox()
|
||||
self.form.setWindowTitle(translate('PathPreferencesPathDressup', 'Dressups'))
|
||||
pages = []
|
||||
for dressup in _dressups:
|
||||
page = dressup.preferencesPage()
|
||||
if hasattr(page, 'icon') and page.icon:
|
||||
self.form.addItem(page.form, page.icon, page.label)
|
||||
else:
|
||||
self.form.addItem(page.form, page.label)
|
||||
pages.append(page)
|
||||
self.pages = pages
|
||||
|
||||
def saveSettings(self):
|
||||
for page in self.pages:
|
||||
page.saveSettings()
|
||||
|
||||
def loadSettings(self):
|
||||
for page in self.pages:
|
||||
page.loadSettings()
|
||||
|
||||
@@ -29,7 +29,7 @@ from PathScripts.PathPreferences import PathPreferences
|
||||
from PathScripts.PathPostProcessor import PostProcessor
|
||||
|
||||
|
||||
class Page:
|
||||
class JobPreferencesPage:
|
||||
def __init__(self, parent=None):
|
||||
self.form = FreeCADGui.PySideUic.loadUi(":preferences/PathJob.ui")
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ if FreeCAD.GuiUp:
|
||||
# Qt tanslation handling
|
||||
try:
|
||||
_encoding = QtGui.QApplication.UnicodeUTF8
|
||||
|
||||
def translate(context, text, disambig=None):
|
||||
return QtGui.QApplication.translate(context, text, disambig, _encoding)
|
||||
except AttributeError:
|
||||
@@ -51,68 +52,51 @@ __url__ = "http://www.freecadweb.org"
|
||||
|
||||
"""Path Profile object and FreeCAD command"""
|
||||
|
||||
|
||||
class ObjectProfile:
|
||||
|
||||
def __init__(self, obj):
|
||||
obj.addProperty("App::PropertyLinkSubList", "Base", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","The base geometry of this toolpath"))
|
||||
obj.addProperty("App::PropertyBool", "Active", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","Make False, to prevent operation from generating code"))
|
||||
obj.addProperty("App::PropertyString", "Comment", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","An optional comment for this profile"))
|
||||
obj.addProperty("App::PropertyString", "UserLabel", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","User Assigned Label"))
|
||||
obj.addProperty("App::PropertyLinkSubList", "Base", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The base geometry of this toolpath"))
|
||||
obj.addProperty("App::PropertyBool", "Active", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "Make False, to prevent operation from generating code"))
|
||||
obj.addProperty("App::PropertyString", "Comment", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "An optional comment for this profile"))
|
||||
obj.addProperty("App::PropertyString", "UserLabel", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "User Assigned Label"))
|
||||
|
||||
obj.addProperty("App::PropertyIntegerConstraint", "ToolNumber", "Tool", "The tool number in use")
|
||||
obj.ToolNumber = (0, 0, 1000, 1)
|
||||
obj.setEditorMode('ToolNumber', 1) # make this read only
|
||||
obj.addProperty("App::PropertyString", "ToolDescription", "Tool", "The description of the tool ")
|
||||
obj.setEditorMode('ToolDescription', 1) # make this read only
|
||||
obj.setEditorMode('ToolDescription', 1) # make this read only
|
||||
|
||||
# Depth Properties
|
||||
obj.addProperty("App::PropertyDistance", "ClearanceHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","The height needed to clear clamps and obstructions"))
|
||||
obj.addProperty("App::PropertyDistance", "SafeHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","Rapid Safety Height between locations."))
|
||||
obj.addProperty("App::PropertyDistance", "StepDown", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","Incremental Step Down of Tool"))
|
||||
#obj.StepDown = (1, 0.01, 1000, 0.5)
|
||||
obj.addProperty("App::PropertyDistance", "StartDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","Starting Depth of Tool- first cut depth in Z"))
|
||||
obj.addProperty("App::PropertyDistance", "FinalDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","Final Depth of Tool- lowest value in Z"))
|
||||
obj.addProperty("App::PropertyDistance", "ClearanceHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "The height needed to clear clamps and obstructions"))
|
||||
obj.addProperty("App::PropertyDistance", "SafeHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Rapid Safety Height between locations."))
|
||||
obj.addProperty("App::PropertyDistance", "StepDown", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Incremental Step Down of Tool"))
|
||||
obj.addProperty("App::PropertyDistance", "StartDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Starting Depth of Tool- first cut depth in Z"))
|
||||
obj.addProperty("App::PropertyDistance", "FinalDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Final Depth of Tool- lowest value in Z"))
|
||||
|
||||
# Start Point Properties
|
||||
obj.addProperty("App::PropertyVector", "StartPoint", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property","The start point of this path"))
|
||||
obj.addProperty("App::PropertyBool", "UseStartPoint", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property","make True, if specifying a Start Point"))
|
||||
obj.addProperty("App::PropertyLength", "ExtendAtStart", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property","extra length of tool path before start of part edge"))
|
||||
obj.addProperty("App::PropertyLength", "LeadInLineLen", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property","length of straight segment of toolpath that comes in at angle to first part edge"))
|
||||
obj.addProperty("App::PropertyVector", "StartPoint", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "The start point of this path"))
|
||||
obj.addProperty("App::PropertyBool", "UseStartPoint", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "make True, if specifying a Start Point"))
|
||||
obj.addProperty("App::PropertyLength", "ExtendAtStart", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "extra length of tool path before start of part edge"))
|
||||
obj.addProperty("App::PropertyLength", "LeadInLineLen", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "length of straight segment of toolpath that comes in at angle to first part edge"))
|
||||
|
||||
# End Point Properties
|
||||
obj.addProperty("App::PropertyBool", "UseEndPoint", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property","make True, if specifying an End Point"))
|
||||
obj.addProperty("App::PropertyLength", "ExtendAtEnd", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property","extra length of tool path after end of part edge"))
|
||||
obj.addProperty("App::PropertyLength", "LeadOutLineLen", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property","length of straight segment of toolpath that comes in at angle to last part edge"))
|
||||
obj.addProperty("App::PropertyVector", "EndPoint", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property","The end point of this path"))
|
||||
obj.addProperty("App::PropertyBool", "UseEndPoint", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "make True, if specifying an End Point"))
|
||||
obj.addProperty("App::PropertyLength", "ExtendAtEnd", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "extra length of tool path after end of part edge"))
|
||||
obj.addProperty("App::PropertyLength", "LeadOutLineLen", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "length of straight segment of toolpath that comes in at angle to last part edge"))
|
||||
obj.addProperty("App::PropertyVector", "EndPoint", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "The end point of this path"))
|
||||
|
||||
# Profile Properties
|
||||
obj.addProperty("App::PropertyEnumeration", "Side", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","Side of edge that tool should cut"))
|
||||
obj.addProperty("App::PropertyEnumeration", "Side", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Side of edge that tool should cut"))
|
||||
obj.Side = ['Left', 'Right', 'On'] # side of profile that cutter is on in relation to direction of profile
|
||||
obj.addProperty("App::PropertyEnumeration", "Direction", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","The direction that the toolpath should go around the part ClockWise CW or CounterClockWise CCW"))
|
||||
obj.addProperty("App::PropertyEnumeration", "Direction", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "The direction that the toolpath should go around the part ClockWise CW or CounterClockWise CCW"))
|
||||
obj.Direction = ['CW', 'CCW'] # this is the direction that the profile runs
|
||||
obj.addProperty("App::PropertyBool", "UseComp", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","make True, if using Cutter Radius Compensation"))
|
||||
obj.addProperty("App::PropertyBool", "UseComp", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "make True, if using Cutter Radius Compensation"))
|
||||
|
||||
obj.addProperty("App::PropertyDistance", "RollRadius", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","Radius at start and end"))
|
||||
obj.addProperty("App::PropertyDistance", "OffsetExtra", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","Extra value to stay away from final profile- good for roughing toolpath"))
|
||||
obj.addProperty("App::PropertyLength", "SegLen", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","Tesselation value for tool paths made from beziers, bsplines, and ellipses"))
|
||||
obj.addProperty("App::PropertyAngle", "PlungeAngle", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","Plunge angle with which the tool enters the work piece. Straight down is 90 degrees, if set small enough or zero the tool will descent exactly one layer depth down per turn"))
|
||||
obj.addProperty("App::PropertyBool", "processHoles", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","Profile holes as well as the outline"))
|
||||
obj.addProperty("App::PropertyBool", "processPerimeter", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","Profile the outline"))
|
||||
|
||||
obj.addProperty("App::PropertyVectorList", "locs", "Tags", QtCore.QT_TRANSLATE_NOOP("App::Property","List of holding tag locations"))
|
||||
|
||||
obj.addProperty("App::PropertyFloatList", "angles", "Tags", QtCore.QT_TRANSLATE_NOOP("App::Property","List of angles for the holding tags"))
|
||||
obj.addProperty("App::PropertyFloatList", "heights", "Tags", QtCore.QT_TRANSLATE_NOOP("App::Property","List of angles for the holding tags"))
|
||||
obj.addProperty("App::PropertyFloatList", "lengths", "Tags", QtCore.QT_TRANSLATE_NOOP("App::Property","List of angles for the holding tags"))
|
||||
locations = []
|
||||
angles = []
|
||||
lengths = []
|
||||
heights = []
|
||||
|
||||
obj.locs = locations
|
||||
obj.angles = angles
|
||||
obj.lengths = lengths
|
||||
obj.heights = heights
|
||||
obj.addProperty("App::PropertyDistance", "RollRadius", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Radius at start and end"))
|
||||
obj.addProperty("App::PropertyDistance", "OffsetExtra", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Extra value to stay away from final profile- good for roughing toolpath"))
|
||||
obj.addProperty("App::PropertyBool", "processHoles", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Profile holes as well as the outline"))
|
||||
obj.addProperty("App::PropertyBool", "processPerimeter", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Profile the outline"))
|
||||
|
||||
obj.Proxy = self
|
||||
|
||||
@@ -145,7 +129,7 @@ class ObjectProfile:
|
||||
obj.FinalDepth = fbb.ZMin
|
||||
elif fbb.ZMax == fbb.ZMin and fbb.ZMax > bb.ZMin: # face/shelf
|
||||
obj.FinalDepth = fbb.ZMin
|
||||
else: #catch all
|
||||
else: # catch all
|
||||
obj.FinalDepth = bb.ZMin
|
||||
except:
|
||||
obj.StartDepth = 5.0
|
||||
@@ -167,8 +151,8 @@ class ObjectProfile:
|
||||
|
||||
def _buildPathLibarea(self, obj, edgelist, isHole):
|
||||
import PathScripts.PathKurveUtils as PathKurveUtils
|
||||
import math
|
||||
import area
|
||||
# import math
|
||||
# import area
|
||||
output = ""
|
||||
if obj.Comment != "":
|
||||
output += '(' + str(obj.Comment)+')\n'
|
||||
@@ -220,14 +204,6 @@ print "y - " + str(point.y)
|
||||
I need to access the location vector, length, angle in radians and height.
|
||||
|
||||
'''
|
||||
PathKurveUtils.clear_tags()
|
||||
for i in range(len(obj.locs)):
|
||||
tag = obj.locs[i]
|
||||
h = obj.heights[i]
|
||||
l = obj.lengths[i]
|
||||
a = math.radians(obj.angles[i])
|
||||
PathKurveUtils.add_tag(area.Point(tag.x, tag.y), l, a, h)
|
||||
|
||||
depthparams = depth_params(
|
||||
obj.ClearanceHeight.Value,
|
||||
obj.SafeHeight.Value, obj.StartDepth.Value, obj.StepDown.Value, 0.0,
|
||||
@@ -286,7 +262,7 @@ print "y - " + str(point.y)
|
||||
for b in obj.Base:
|
||||
for sub in b[1]:
|
||||
shape = getattr(b[0].Shape, sub)
|
||||
if isinstance (shape, Part.Face):
|
||||
if isinstance(shape, Part.Face):
|
||||
faces.append(shape)
|
||||
if numpy.isclose(abs(shape.normalAt(0, 0).z), 1): # horizontal face
|
||||
holes += shape.Wires[1:]
|
||||
@@ -295,7 +271,7 @@ print "y - " + str(point.y)
|
||||
print ("found a base object which is not a face. Can't continue.")
|
||||
return
|
||||
profileshape = Part.makeCompound(faces)
|
||||
profilewire = TechDraw.findShapeOutline(profileshape, 1, Vector(0,0,1))
|
||||
profilewire = TechDraw.findShapeOutline(profileshape, 1, Vector(0, 0, 1))
|
||||
|
||||
if obj.processHoles:
|
||||
for wire in holes:
|
||||
@@ -346,45 +322,9 @@ class _ViewProviderProfile:
|
||||
return None
|
||||
|
||||
|
||||
class _CommandAddTag:
|
||||
def GetResources(self):
|
||||
return {'Pixmap': 'Path-Holding',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Path_Profile", "Add Holding Tag"),
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Path_Profile", "Add Holding Tag")}
|
||||
|
||||
def IsActive(self):
|
||||
return FreeCAD.ActiveDocument is not None
|
||||
|
||||
def setpoint(self, point, o):
|
||||
obj = FreeCADGui.Selection.getSelection()[0]
|
||||
obj.StartPoint.x = point.x
|
||||
obj.StartPoint.y = point.y
|
||||
loc = obj.locs
|
||||
h = obj.heights
|
||||
l = obj.lengths
|
||||
a = obj.angles
|
||||
|
||||
x = point.x
|
||||
y = point.y
|
||||
z = float(0.0)
|
||||
loc.append(Vector(x, y, z))
|
||||
h.append(4.0)
|
||||
l.append(5.0)
|
||||
a.append(45.0)
|
||||
|
||||
obj.locs = loc
|
||||
obj.heights = h
|
||||
obj.lengths = l
|
||||
obj.angles = a
|
||||
|
||||
def Activated(self):
|
||||
|
||||
FreeCADGui.Snapper.getPoint(callback=self.setpoint)
|
||||
|
||||
|
||||
class _CommandSetStartPoint:
|
||||
def GetResources(self):
|
||||
return {'Pixmap': 'Path-Holding',
|
||||
return {'Pixmap': 'Path-StartPoint',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Path_Profile", "Pick Start Point"),
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Path_Profile", "Pick Start Point")}
|
||||
|
||||
@@ -403,7 +343,7 @@ class _CommandSetStartPoint:
|
||||
|
||||
class _CommandSetEndPoint:
|
||||
def GetResources(self):
|
||||
return {'Pixmap': 'Path-Holding',
|
||||
return {'Pixmap': 'Path-EndPoint',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Path_Profile", "Pick End Point"),
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Path_Profile", "Pick End Point")}
|
||||
|
||||
@@ -457,7 +397,6 @@ class CommandPathProfile:
|
||||
FreeCADGui.doCommand('obj.UseComp = False')
|
||||
FreeCADGui.doCommand('obj.processHoles = False')
|
||||
FreeCADGui.doCommand('obj.processPerimeter = True')
|
||||
FreeCADGui.doCommand('obj.PlungeAngle = 90.0')
|
||||
FreeCADGui.doCommand('PathScripts.PathProfile._ViewProviderProfile(obj.ViewObject)')
|
||||
FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)')
|
||||
|
||||
@@ -486,24 +425,21 @@ class TaskPanel:
|
||||
|
||||
def getFields(self):
|
||||
if self.obj:
|
||||
|
||||
if hasattr(self.obj, "StartDepth"):
|
||||
self.obj.StartDepth = self.form.startDepth.text()
|
||||
self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value
|
||||
if hasattr(self.obj, "FinalDepth"):
|
||||
self.obj.FinalDepth = self.form.finalDepth.text()
|
||||
self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value
|
||||
if hasattr(self.obj, "SafeHeight"):
|
||||
self.obj.SafeHeight = self.form.safeHeight.text()
|
||||
self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value
|
||||
if hasattr(self.obj, "ClearanceHeight"):
|
||||
self.obj.ClearanceHeight = self.form.clearanceHeight.text()
|
||||
self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value
|
||||
if hasattr(self.obj, "StepDown"):
|
||||
self.obj.StepDown = self.form.stepDown.text()
|
||||
self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value
|
||||
if hasattr(self.obj, "OffsetExtra"):
|
||||
self.obj.OffsetExtra = self.form.extraOffset.text()
|
||||
if hasattr(self.obj, "SegLen"):
|
||||
self.obj.SegLen = self.form.segLen.value()
|
||||
self.obj.OffsetExtra = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value
|
||||
if hasattr(self.obj, "RollRadius"):
|
||||
self.obj.RollRadius = self.form.rollRadius.text()
|
||||
if hasattr(self.obj, "PlungeAngle"):
|
||||
self.obj.PlungeAngle = str(self.form.plungeAngle.value())
|
||||
self.obj.RollRadius = FreeCAD.Units.Quantity(self.form.rollRadius.text()).Value
|
||||
if hasattr(self.obj, "UseComp"):
|
||||
self.obj.UseComp = self.form.useCompensation.isChecked()
|
||||
if hasattr(self.obj, "UseStartPoint"):
|
||||
@@ -521,15 +457,13 @@ class TaskPanel:
|
||||
self.obj.Proxy.execute(self.obj)
|
||||
|
||||
def setFields(self):
|
||||
self.form.startDepth.setText(str(self.obj.StartDepth.Value))
|
||||
self.form.finalDepth.setText(str(self.obj.FinalDepth.Value))
|
||||
self.form.safeHeight.setText(str(self.obj.SafeHeight.Value))
|
||||
self.form.clearanceHeight.setText(str(self.obj.ClearanceHeight.Value))
|
||||
self.form.stepDown.setText(str(self.obj.StepDown))
|
||||
self.form.extraOffset.setText(str(self.obj.OffsetExtra.Value))
|
||||
self.form.segLen.setValue(self.obj.SegLen.Value)
|
||||
self.form.rollRadius.setText(str(self.obj.RollRadius.Value))
|
||||
self.form.plungeAngle.setValue(self.obj.PlungeAngle.Value)
|
||||
self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.extraOffset.setText(FreeCAD.Units.Quantity(self.obj.OffsetExtra.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.rollRadius.setText(FreeCAD.Units.Quantity(self.obj.RollRadius.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.useCompensation.setChecked(self.obj.UseComp)
|
||||
self.form.useStartPoint.setChecked(self.obj.UseStartPoint)
|
||||
self.form.useEndPoint.setChecked(self.obj.UseEndPoint)
|
||||
@@ -556,21 +490,8 @@ class TaskPanel:
|
||||
self.form.baseList.addItem(i[0].Name + "." + sub)
|
||||
self.form.baseList.blockSignals(False)
|
||||
|
||||
self.form.tagTree.blockSignals(True)
|
||||
for i in range(len(self.obj.locs)):
|
||||
item = QtGui.QTreeWidgetItem(self.form.tagTree)
|
||||
item.setText(0, str(i+1))
|
||||
l = self.obj.locs[i]
|
||||
item.setText(1, str(l.x)+", " + str(l.y) + ", " + str(l.z))
|
||||
item.setText(2, str(self.obj.heights[i]))
|
||||
item.setText(3, str(self.obj.lengths[i]))
|
||||
item.setText(4, str(self.obj.angles[i]))
|
||||
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
|
||||
item.setTextAlignment(0, QtCore.Qt.AlignLeft)
|
||||
self.form.tagTree.blockSignals(False)
|
||||
self.form.update()
|
||||
|
||||
|
||||
def open(self):
|
||||
self.s = SelObserver()
|
||||
# install the function mode resident
|
||||
@@ -601,7 +522,6 @@ class TaskPanel:
|
||||
for sub in i[1]:
|
||||
self.form.baseList.addItem(i[0].Name + "." + sub)
|
||||
|
||||
|
||||
def deleteBase(self):
|
||||
dlist = self.form.baseList.selectedItems()
|
||||
newlist = []
|
||||
@@ -644,90 +564,6 @@ class TaskPanel:
|
||||
def getStandardButtons(self):
|
||||
return int(QtGui.QDialogButtonBox.Ok)
|
||||
|
||||
def edit(self, item, column):
|
||||
if not self.updating:
|
||||
self.resetObject()
|
||||
|
||||
def resetObject(self, remove=None):
|
||||
"transfers the values from the widget to the object"
|
||||
loc = []
|
||||
h = []
|
||||
l = []
|
||||
a = []
|
||||
|
||||
for i in range(self.form.tagTree.topLevelItemCount()):
|
||||
it = self.form.tagTree.findItems(
|
||||
str(i+1), QtCore.Qt.MatchExactly, 0)[0]
|
||||
if (remove is None) or (remove != i):
|
||||
if it.text(1):
|
||||
x = float(it.text(1).split()[0].rstrip(","))
|
||||
y = float(it.text(1).split()[1].rstrip(","))
|
||||
z = float(it.text(1).split()[2].rstrip(","))
|
||||
loc.append(Vector(x, y, z))
|
||||
|
||||
else:
|
||||
loc.append(0.0)
|
||||
if it.text(2):
|
||||
h.append(float(it.text(2)))
|
||||
else:
|
||||
h.append(4.0)
|
||||
if it.text(3):
|
||||
l.append(float(it.text(3)))
|
||||
else:
|
||||
l.append(5.0)
|
||||
if it.text(4):
|
||||
a.append(float(it.text(4)))
|
||||
else:
|
||||
a.append(45.0)
|
||||
|
||||
self.obj.locs = loc
|
||||
self.obj.heights = h
|
||||
self.obj.lengths = l
|
||||
self.obj.angles = a
|
||||
|
||||
self.obj.touch()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
def addElement(self):
|
||||
self.updating = True
|
||||
|
||||
item = QtGui.QTreeWidgetItem(self.form.tagTree)
|
||||
item.setText(0, str(self.form.tagTree.topLevelItemCount()))
|
||||
item.setText(1, "0.0, 0.0, 0.0")
|
||||
item.setText(2, str(float(4.0)))
|
||||
item.setText(3, str(float(10.0)))
|
||||
item.setText(4, str(float(45.0)))
|
||||
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
|
||||
self.updating = False
|
||||
|
||||
self.resetObject()
|
||||
|
||||
def removeElement(self):
|
||||
it = self.form.tagTree.currentItem()
|
||||
if it:
|
||||
nr = int(it.text(0))-1
|
||||
self.resetObject(remove=nr)
|
||||
self.update()
|
||||
|
||||
def update(self):
|
||||
'fills the treewidget'
|
||||
self.updating = True
|
||||
self.form.tagTree.clear()
|
||||
if self.obj:
|
||||
for i in range(len(self.obj.locs)):
|
||||
item = QtGui.QTreeWidgetItem(self.form.tagTree)
|
||||
item.setText(0, str(i+1))
|
||||
l = self.obj.locs[i]
|
||||
item.setText(1, str(l.x) + ", " + str(l.y) + ", " + str(l.z))
|
||||
item.setText(2, str(self.obj.heights[i]))
|
||||
item.setText(3, str(self.obj.lengths[i]))
|
||||
item.setText(4, str(self.obj.angles[i]))
|
||||
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
|
||||
item.setTextAlignment(0, QtCore.Qt.AlignLeft)
|
||||
self.updating = False
|
||||
return
|
||||
|
||||
|
||||
def setupUi(self):
|
||||
|
||||
# Connect Signals and Slots
|
||||
@@ -753,19 +589,10 @@ class TaskPanel:
|
||||
self.form.useStartPoint.clicked.connect(self.getFields)
|
||||
self.form.useEndPoint.clicked.connect(self.getFields)
|
||||
self.form.extraOffset.editingFinished.connect(self.getFields)
|
||||
self.form.segLen.editingFinished.connect(self.getFields)
|
||||
self.form.rollRadius.editingFinished.connect(self.getFields)
|
||||
self.form.processHoles.clicked.connect(self.getFields)
|
||||
self.form.processPerimeter.clicked.connect(self.getFields)
|
||||
|
||||
# Tag Form
|
||||
QtCore.QObject.connect(
|
||||
self.form.tagTree,
|
||||
QtCore.SIGNAL("itemChanged(QTreeWidgetItem *, int)"),
|
||||
self.edit)
|
||||
self.form.addTag.clicked.connect(self.addElement)
|
||||
self.form.deleteTag.clicked.connect(self.removeElement)
|
||||
|
||||
self.setFields()
|
||||
|
||||
sel = FreeCADGui.Selection.getSelectionEx()
|
||||
@@ -790,7 +617,6 @@ class SelObserver:
|
||||
if FreeCAD.GuiUp:
|
||||
# register the FreeCAD command
|
||||
FreeCADGui.addCommand('Path_Profile', CommandPathProfile())
|
||||
FreeCADGui.addCommand('Add_Tag', _CommandAddTag())
|
||||
FreeCADGui.addCommand('Set_StartPoint', _CommandSetStartPoint())
|
||||
FreeCADGui.addCommand('Set_EndPoint', _CommandSetEndPoint())
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
import FreeCAD
|
||||
import Path
|
||||
from FreeCAD import Vector
|
||||
from PathScripts import PathUtils
|
||||
from PathScripts.PathUtils import depth_params
|
||||
from DraftGeomUtils import findWires
|
||||
@@ -50,70 +49,49 @@ __url__ = "http://www.freecadweb.org"
|
||||
|
||||
"""Path Profile object and FreeCAD command for operating on sets of edges"""
|
||||
|
||||
|
||||
class ObjectProfile:
|
||||
|
||||
def __init__(self, obj):
|
||||
obj.addProperty("App::PropertyLinkSubList", "Base", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","The base geometry of this toolpath"))
|
||||
obj.addProperty("App::PropertyBool", "Active", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","Make False, to prevent operation from generating code"))
|
||||
obj.addProperty("App::PropertyString", "Comment", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","An optional comment for this profile"))
|
||||
obj.addProperty("App::PropertyString", "UserLabel", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","User Assigned Label"))
|
||||
obj.addProperty("App::PropertyLinkSubList", "Base", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The base geometry of this toolpath"))
|
||||
obj.addProperty("App::PropertyBool", "Active", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "Make False, to prevent operation from generating code"))
|
||||
obj.addProperty("App::PropertyString", "Comment", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "An optional comment for this profile"))
|
||||
obj.addProperty("App::PropertyString", "UserLabel", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "User Assigned Label"))
|
||||
|
||||
# obj.addProperty("App::PropertyEnumeration", "Algorithm", "Algorithm", "The library or algorithm used to generate the path")
|
||||
# obj.Algorithm = ['OCC Native', 'libarea']
|
||||
|
||||
obj.addProperty("App::PropertyIntegerConstraint", "ToolNumber", "Tool", QtCore.QT_TRANSLATE_NOOP("App::Property","The tool number in use"))
|
||||
obj.addProperty("App::PropertyIntegerConstraint", "ToolNumber", "Tool", QtCore.QT_TRANSLATE_NOOP("App::Property", "The tool number in use"))
|
||||
obj.ToolNumber = (0, 0, 1000, 1)
|
||||
obj.setEditorMode('ToolNumber', 1) # make this read only
|
||||
obj.addProperty("App::PropertyString", "ToolDescription", "Tool", QtCore.QT_TRANSLATE_NOOP("App::Property","The description of the tool"))
|
||||
obj.setEditorMode('ToolDescription', 1) # make this read onlyt
|
||||
obj.addProperty("App::PropertyString", "ToolDescription", "Tool", QtCore.QT_TRANSLATE_NOOP("App::Property", "The description of the tool"))
|
||||
obj.setEditorMode('ToolDescription', 1) # make this read onlyt
|
||||
|
||||
# Depth Properties
|
||||
obj.addProperty("App::PropertyDistance", "ClearanceHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","The height needed to clear clamps and obstructions"))
|
||||
obj.addProperty("App::PropertyDistance", "SafeHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","Rapid Safety Height between locations"))
|
||||
obj.addProperty("App::PropertyDistance", "StepDown", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","Incremental Step Down of Tool"))
|
||||
#obj.StepDown = (1, 0.01, 1000, 0.5)
|
||||
obj.addProperty("App::PropertyDistance", "StartDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","Starting Depth of Tool- first cut depth in Z"))
|
||||
obj.addProperty("App::PropertyDistance", "FinalDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","Final Depth of Tool- lowest value in Z"))
|
||||
obj.addProperty("App::PropertyDistance", "ClearanceHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "The height needed to clear clamps and obstructions"))
|
||||
obj.addProperty("App::PropertyDistance", "SafeHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Rapid Safety Height between locations"))
|
||||
obj.addProperty("App::PropertyDistance", "StepDown", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Incremental Step Down of Tool"))
|
||||
obj.addProperty("App::PropertyDistance", "StartDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Starting Depth of Tool- first cut depth in Z"))
|
||||
obj.addProperty("App::PropertyDistance", "FinalDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Final Depth of Tool- lowest value in Z"))
|
||||
|
||||
# Start Point Properties
|
||||
obj.addProperty("App::PropertyVector", "StartPoint", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property","The start point of this path"))
|
||||
obj.addProperty("App::PropertyBool", "UseStartPoint", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property","make True, if specifying a Start Point"))
|
||||
obj.addProperty("App::PropertyLength", "ExtendAtStart", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property","extra length of tool path before start of part edge"))
|
||||
obj.addProperty("App::PropertyLength", "LeadInLineLen", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property","length of straight segment of toolpath that comes in at angle to first part edge"))
|
||||
obj.addProperty("App::PropertyVector", "StartPoint", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "The start point of this path"))
|
||||
obj.addProperty("App::PropertyBool", "UseStartPoint", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "make True, if specifying a Start Point"))
|
||||
obj.addProperty("App::PropertyLength", "ExtendAtStart", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "extra length of tool path before start of part edge"))
|
||||
obj.addProperty("App::PropertyLength", "LeadInLineLen", "Start Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "length of straight segment of toolpath that comes in at angle to first part edge"))
|
||||
|
||||
# End Point Properties
|
||||
obj.addProperty("App::PropertyBool", "UseEndPoint", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property","make True, if specifying an End Point"))
|
||||
obj.addProperty("App::PropertyLength", "ExtendAtEnd", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property","extra length of tool path after end of part edge"))
|
||||
obj.addProperty("App::PropertyLength", "LeadOutLineLen", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property","length of straight segment of toolpath that comes in at angle to last part edge"))
|
||||
obj.addProperty("App::PropertyVector", "EndPoint", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property","The end point of this path"))
|
||||
obj.addProperty("App::PropertyBool", "UseEndPoint", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "make True, if specifying an End Point"))
|
||||
obj.addProperty("App::PropertyLength", "ExtendAtEnd", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "extra length of tool path after end of part edge"))
|
||||
obj.addProperty("App::PropertyLength", "LeadOutLineLen", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "length of straight segment of toolpath that comes in at angle to last part edge"))
|
||||
obj.addProperty("App::PropertyVector", "EndPoint", "End Point", QtCore.QT_TRANSLATE_NOOP("App::Property", "The end point of this path"))
|
||||
|
||||
# Profile Properties
|
||||
obj.addProperty("App::PropertyEnumeration", "Side", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","Side of edge that tool should cut"))
|
||||
obj.addProperty("App::PropertyEnumeration", "Side", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Side of edge that tool should cut"))
|
||||
obj.Side = ['Left', 'Right', 'On'] # side of profile that cutter is on in relation to direction of profile
|
||||
obj.addProperty("App::PropertyEnumeration", "Direction", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","The direction that the toolpath should go around the part ClockWise CW or CounterClockWise CCW"))
|
||||
obj.addProperty("App::PropertyEnumeration", "Direction", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "The direction that the toolpath should go around the part ClockWise CW or CounterClockWise CCW"))
|
||||
obj.Direction = ['CW', 'CCW'] # this is the direction that the profile runs
|
||||
obj.addProperty("App::PropertyBool", "UseComp", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","make True, if using Cutter Radius Compensation"))
|
||||
obj.addProperty("App::PropertyBool", "UseComp", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "make True, if using Cutter Radius Compensation"))
|
||||
|
||||
obj.addProperty("App::PropertyDistance", "RollRadius", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","Radius at start and end"))
|
||||
obj.addProperty("App::PropertyDistance", "OffsetExtra", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","Extra value to stay away from final profile- good for roughing toolpath"))
|
||||
obj.addProperty("App::PropertyLength", "SegLen", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","Tesselation value for tool paths made from beziers, bsplines, and ellipses"))
|
||||
obj.addProperty("App::PropertyAngle", "PlungeAngle", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property","Plunge angle with which the tool enters the work piece. Straight down is 90 degrees, if set small enough or zero the tool will descent exactly one layer depth down per turn"))
|
||||
|
||||
obj.addProperty("App::PropertyVectorList", "locs", "Tags", QtCore.QT_TRANSLATE_NOOP("App::Property","List of holding tag locations"))
|
||||
|
||||
obj.addProperty("App::PropertyFloatList", "angles", "Tags", QtCore.QT_TRANSLATE_NOOP("App::Property","List of angles for the holding tags"))
|
||||
obj.addProperty("App::PropertyFloatList", "heights", "Tags", QtCore.QT_TRANSLATE_NOOP("App::Property","List of angles for the holding tags"))
|
||||
obj.addProperty("App::PropertyFloatList", "lengths", "Tags", QtCore.QT_TRANSLATE_NOOP("App::Property","List of angles for the holding tags"))
|
||||
locations = []
|
||||
angles = []
|
||||
lengths = []
|
||||
heights = []
|
||||
|
||||
obj.locs = locations
|
||||
obj.angles = angles
|
||||
obj.lengths = lengths
|
||||
obj.heights = heights
|
||||
#obj.ToolDescription = "UNDEFINED"
|
||||
obj.addProperty("App::PropertyDistance", "RollRadius", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Radius at start and end"))
|
||||
obj.addProperty("App::PropertyDistance", "OffsetExtra", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Extra value to stay away from final profile- good for roughing toolpath"))
|
||||
|
||||
obj.Proxy = self
|
||||
|
||||
@@ -146,18 +124,13 @@ class ObjectProfile:
|
||||
obj.FinalDepth = fbb.ZMin
|
||||
elif fbb.ZMax == fbb.ZMin and fbb.ZMax > bb.ZMin: # face/shelf
|
||||
obj.FinalDepth = fbb.ZMin
|
||||
else: #catch all
|
||||
else: # catch all
|
||||
obj.FinalDepth = bb.ZMin
|
||||
except:
|
||||
obj.StartDepth = 5.0
|
||||
obj.ClearanceHeight = 10.0
|
||||
obj.SafeHeight = 8.0
|
||||
|
||||
# if bb.XLength == fbb.XLength and bb.YLength == fbb.YLength:
|
||||
# obj.Side = "Left"
|
||||
# else:
|
||||
# obj.Side = "Right"
|
||||
|
||||
item = (ss, sub)
|
||||
if item in baselist:
|
||||
FreeCAD.Console.PrintWarning("this object already in the list" + "\n")
|
||||
@@ -168,8 +141,8 @@ class ObjectProfile:
|
||||
|
||||
def _buildPathLibarea(self, obj, edgelist):
|
||||
import PathScripts.PathKurveUtils as PathKurveUtils
|
||||
import math
|
||||
import area
|
||||
# import math
|
||||
# import area
|
||||
output = ""
|
||||
if obj.Comment != "":
|
||||
output += '(' + str(obj.Comment)+')\n'
|
||||
@@ -216,14 +189,6 @@ print "y - " + str(point.y)
|
||||
I need to access the location vector, length, angle in radians and height.
|
||||
|
||||
'''
|
||||
PathKurveUtils.clear_tags()
|
||||
for i in range(len(obj.locs)):
|
||||
tag = obj.locs[i]
|
||||
h = obj.heights[i]
|
||||
l = obj.lengths[i]
|
||||
a = math.radians(obj.angles[i])
|
||||
PathKurveUtils.add_tag(area.Point(tag.x, tag.y), l, a, h)
|
||||
|
||||
depthparams = depth_params(
|
||||
obj.ClearanceHeight.Value,
|
||||
obj.SafeHeight.Value, obj.StartDepth.Value, obj.StepDown.Value, 0.0,
|
||||
@@ -243,8 +208,6 @@ print "y - " + str(point.y)
|
||||
output = ""
|
||||
|
||||
toolLoad = PathUtils.getLastToolLoad(obj)
|
||||
# obj.ToolController = PathUtils.getToolControllers(obj)
|
||||
# toolLoad = PathUtils.getToolLoad(obj, obj.ToolController)
|
||||
|
||||
if toolLoad is None or toolLoad.ToolNumber == 0:
|
||||
self.vertFeed = 100
|
||||
@@ -279,8 +242,6 @@ print "y - " + str(point.y)
|
||||
output += "(Uncompensated Tool Path)"
|
||||
|
||||
if obj.Base:
|
||||
# hfaces = []
|
||||
# vfaces = []
|
||||
wires = []
|
||||
|
||||
for b in obj.Base:
|
||||
@@ -332,45 +293,9 @@ class _ViewProviderProfile:
|
||||
return None
|
||||
|
||||
|
||||
class _CommandAddTag:
|
||||
def GetResources(self):
|
||||
return {'Pixmap': 'Path-Holding',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Path_Profile", "Add Holding Tag"),
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Path_Profile", "Add Holding Tag")}
|
||||
|
||||
def IsActive(self):
|
||||
return FreeCAD.ActiveDocument is not None
|
||||
|
||||
def setpoint(self, point, o):
|
||||
obj = FreeCADGui.Selection.getSelection()[0]
|
||||
obj.StartPoint.x = point.x
|
||||
obj.StartPoint.y = point.y
|
||||
loc = obj.locs
|
||||
h = obj.heights
|
||||
l = obj.lengths
|
||||
a = obj.angles
|
||||
|
||||
x = point.x
|
||||
y = point.y
|
||||
z = float(0.0)
|
||||
loc.append(Vector(x, y, z))
|
||||
h.append(4.0)
|
||||
l.append(5.0)
|
||||
a.append(45.0)
|
||||
|
||||
obj.locs = loc
|
||||
obj.heights = h
|
||||
obj.lengths = l
|
||||
obj.angles = a
|
||||
|
||||
def Activated(self):
|
||||
|
||||
FreeCADGui.Snapper.getPoint(callback=self.setpoint)
|
||||
|
||||
|
||||
class _CommandSetStartPoint:
|
||||
def GetResources(self):
|
||||
return {'Pixmap': 'Path-Holding',
|
||||
return {'Pixmap': 'Path-StartPoint',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Path_Profile", "Pick Start Point"),
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Path_Profile", "Pick Start Point")}
|
||||
|
||||
@@ -389,7 +314,7 @@ class _CommandSetStartPoint:
|
||||
|
||||
class _CommandSetEndPoint:
|
||||
def GetResources(self):
|
||||
return {'Pixmap': 'Path-Holding',
|
||||
return {'Pixmap': 'Path-EndPoint',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Path_Profile", "Pick End Point"),
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Path_Profile", "Pick End Point")}
|
||||
|
||||
@@ -442,8 +367,6 @@ class CommandPathProfileEdges:
|
||||
FreeCADGui.doCommand('obj.OffsetExtra = 0.0')
|
||||
FreeCADGui.doCommand('obj.Direction = "CW"')
|
||||
FreeCADGui.doCommand('obj.UseComp = False')
|
||||
FreeCADGui.doCommand('obj.PlungeAngle = 90.0')
|
||||
#FreeCADGui.doCommand('obj.ActiveTC = None')
|
||||
FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)')
|
||||
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
@@ -454,7 +377,7 @@ class CommandPathProfileEdges:
|
||||
class TaskPanel:
|
||||
def __init__(self):
|
||||
self.form = FreeCADGui.PySideUic.loadUi(":/panels/ProfileEdgesEdit.ui")
|
||||
#self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Path/ProfileEdgesEdit.ui")
|
||||
# self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Path/ProfileEdgesEdit.ui")
|
||||
|
||||
self.updating = False
|
||||
|
||||
@@ -473,32 +396,27 @@ class TaskPanel:
|
||||
|
||||
def getFields(self):
|
||||
if self.obj:
|
||||
|
||||
if hasattr(self.obj, "StartDepth"):
|
||||
self.obj.StartDepth = self.form.startDepth.text()
|
||||
self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value
|
||||
if hasattr(self.obj, "FinalDepth"):
|
||||
self.obj.FinalDepth = self.form.finalDepth.text()
|
||||
self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value
|
||||
if hasattr(self.obj, "SafeHeight"):
|
||||
self.obj.SafeHeight = self.form.safeHeight.text()
|
||||
self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value
|
||||
if hasattr(self.obj, "ClearanceHeight"):
|
||||
self.obj.ClearanceHeight = self.form.clearanceHeight.text()
|
||||
self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value
|
||||
if hasattr(self.obj, "StepDown"):
|
||||
self.obj.StepDown = self.form.stepDown.text()
|
||||
self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value
|
||||
if hasattr(self.obj, "OffsetExtra"):
|
||||
self.obj.OffsetExtra = self.form.extraOffset.text()
|
||||
if hasattr(self.obj, "SegLen"):
|
||||
self.obj.SegLen = self.form.segLen.value()
|
||||
self.obj.OffsetExtra = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value
|
||||
if hasattr(self.obj, "RollRadius"):
|
||||
self.obj.RollRadius = self.form.rollRadius.text()
|
||||
if hasattr(self.obj, "PlungeAngle"):
|
||||
self.obj.PlungeAngle = str(self.form.plungeAngle.value())
|
||||
self.obj.RollRadius = FreeCAD.Units.Quantity(self.form.rollRadius.text()).Value
|
||||
if hasattr(self.obj, "UseComp"):
|
||||
self.obj.UseComp = self.form.useCompensation.isChecked()
|
||||
if hasattr(self.obj, "UseStartPoint"):
|
||||
self.obj.UseStartPoint = self.form.useStartPoint.isChecked()
|
||||
if hasattr(self.obj, "UseEndPoint"):
|
||||
self.obj.UseEndPoint = self.form.useEndPoint.isChecked()
|
||||
# if hasattr(self.obj, "Algorithm"):
|
||||
# self.obj.Algorithm = str(self.form.algorithmSelect.currentText())
|
||||
if hasattr(self.obj, "Side"):
|
||||
self.obj.Side = str(self.form.cutSide.currentText())
|
||||
if hasattr(self.obj, "Direction"):
|
||||
@@ -506,15 +424,13 @@ class TaskPanel:
|
||||
self.obj.Proxy.execute(self.obj)
|
||||
|
||||
def setFields(self):
|
||||
self.form.startDepth.setText(str(self.obj.StartDepth.Value))
|
||||
self.form.finalDepth.setText(str(self.obj.FinalDepth.Value))
|
||||
self.form.safeHeight.setText(str(self.obj.SafeHeight.Value))
|
||||
self.form.clearanceHeight.setText(str(self.obj.ClearanceHeight.Value))
|
||||
self.form.stepDown.setText(str(self.obj.StepDown.Value))
|
||||
self.form.extraOffset.setText(str(self.obj.OffsetExtra.Value))
|
||||
self.form.segLen.setValue(self.obj.SegLen.Value)
|
||||
self.form.rollRadius.setText(str(self.obj.RollRadius.Value))
|
||||
self.form.plungeAngle.setValue(self.obj.PlungeAngle.Value)
|
||||
self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.extraOffset.setText(FreeCAD.Units.Quantity(self.obj.OffsetExtra.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.rollRadius.setText(FreeCAD.Units.Quantity(self.obj.RollRadius.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.useCompensation.setChecked(self.obj.UseComp)
|
||||
self.form.useStartPoint.setChecked(self.obj.UseStartPoint)
|
||||
self.form.useEndPoint.setChecked(self.obj.UseEndPoint)
|
||||
@@ -534,20 +450,6 @@ class TaskPanel:
|
||||
self.form.baseList.addItem(i[0].Name + "." + sub)
|
||||
self.form.baseList.blockSignals(False)
|
||||
|
||||
self.form.tagTree.blockSignals(True)
|
||||
for i in range(len(self.obj.locs)):
|
||||
item = QtGui.QTreeWidgetItem(self.form.tagTree)
|
||||
item.setText(0, str(i+1))
|
||||
l = self.obj.locs[i]
|
||||
item.setText(1, str(l.x)+", " + str(l.y) + ", " + str(l.z))
|
||||
item.setText(2, str(self.obj.heights[i]))
|
||||
item.setText(3, str(self.obj.lengths[i]))
|
||||
item.setText(4, str(self.obj.angles[i]))
|
||||
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
|
||||
item.setTextAlignment(0, QtCore.Qt.AlignLeft)
|
||||
self.form.tagTree.blockSignals(False)
|
||||
|
||||
|
||||
def open(self):
|
||||
self.s = SelObserver()
|
||||
# install the function mode resident
|
||||
@@ -620,90 +522,6 @@ class TaskPanel:
|
||||
def getStandardButtons(self):
|
||||
return int(QtGui.QDialogButtonBox.Ok)
|
||||
|
||||
def edit(self, item, column):
|
||||
if not self.updating:
|
||||
self.resetObject()
|
||||
|
||||
def resetObject(self, remove=None):
|
||||
"transfers the values from the widget to the object"
|
||||
loc = []
|
||||
h = []
|
||||
l = []
|
||||
a = []
|
||||
|
||||
for i in range(self.form.tagTree.topLevelItemCount()):
|
||||
it = self.form.tagTree.findItems(
|
||||
str(i+1), QtCore.Qt.MatchExactly, 0)[0]
|
||||
if (remove is None) or (remove != i):
|
||||
if it.text(1):
|
||||
x = float(it.text(1).split()[0].rstrip(","))
|
||||
y = float(it.text(1).split()[1].rstrip(","))
|
||||
z = float(it.text(1).split()[2].rstrip(","))
|
||||
loc.append(Vector(x, y, z))
|
||||
|
||||
else:
|
||||
loc.append(0.0)
|
||||
if it.text(2):
|
||||
h.append(float(it.text(2)))
|
||||
else:
|
||||
h.append(4.0)
|
||||
if it.text(3):
|
||||
l.append(float(it.text(3)))
|
||||
else:
|
||||
l.append(5.0)
|
||||
if it.text(4):
|
||||
a.append(float(it.text(4)))
|
||||
else:
|
||||
a.append(45.0)
|
||||
|
||||
self.obj.locs = loc
|
||||
self.obj.heights = h
|
||||
self.obj.lengths = l
|
||||
self.obj.angles = a
|
||||
|
||||
self.obj.touch()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
def addElement(self):
|
||||
self.updating = True
|
||||
|
||||
item = QtGui.QTreeWidgetItem(self.form.tagTree)
|
||||
item.setText(0, str(self.form.tagTree.topLevelItemCount()))
|
||||
item.setText(1, "0.0, 0.0, 0.0")
|
||||
item.setText(2, str(float(4.0)))
|
||||
item.setText(3, str(float(10.0)))
|
||||
item.setText(4, str(float(45.0)))
|
||||
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
|
||||
self.updating = False
|
||||
|
||||
self.resetObject()
|
||||
|
||||
def removeElement(self):
|
||||
it = self.form.tagTree.currentItem()
|
||||
if it:
|
||||
nr = int(it.text(0))-1
|
||||
self.resetObject(remove=nr)
|
||||
self.update()
|
||||
|
||||
def update(self):
|
||||
'fills the treewidget'
|
||||
self.updating = True
|
||||
self.form.tagTree.clear()
|
||||
if self.obj:
|
||||
for i in range(len(self.obj.locs)):
|
||||
item = QtGui.QTreeWidgetItem(self.form.tagTree)
|
||||
item.setText(0, str(i+1))
|
||||
l = self.obj.locs[i]
|
||||
item.setText(1, str(l.x) + ", " + str(l.y) + ", " + str(l.z))
|
||||
item.setText(2, str(self.obj.heights[i]))
|
||||
item.setText(3, str(self.obj.lengths[i]))
|
||||
item.setText(4, str(self.obj.angles[i]))
|
||||
item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)
|
||||
item.setTextAlignment(0, QtCore.Qt.AlignLeft)
|
||||
self.updating = False
|
||||
return
|
||||
|
||||
|
||||
def setupUi(self):
|
||||
|
||||
# Connect Signals and Slots
|
||||
@@ -729,17 +547,7 @@ class TaskPanel:
|
||||
self.form.useStartPoint.clicked.connect(self.getFields)
|
||||
self.form.useEndPoint.clicked.connect(self.getFields)
|
||||
self.form.extraOffset.editingFinished.connect(self.getFields)
|
||||
self.form.segLen.editingFinished.connect(self.getFields)
|
||||
self.form.rollRadius.editingFinished.connect(self.getFields)
|
||||
|
||||
# Tag Form
|
||||
QtCore.QObject.connect(
|
||||
self.form.tagTree,
|
||||
QtCore.SIGNAL("itemChanged(QTreeWidgetItem *, int)"),
|
||||
self.edit)
|
||||
self.form.addTag.clicked.connect(self.addElement)
|
||||
self.form.deleteTag.clicked.connect(self.removeElement)
|
||||
|
||||
self.setFields()
|
||||
|
||||
sel = FreeCADGui.Selection.getSelectionEx()
|
||||
@@ -764,8 +572,7 @@ class SelObserver:
|
||||
if FreeCAD.GuiUp:
|
||||
# register the FreeCAD command
|
||||
FreeCADGui.addCommand('Path_Profile_Edges', CommandPathProfileEdges())
|
||||
# FreeCADGui.addCommand('Add_Tag', _CommandAddTag())
|
||||
# FreeCADGui.addCommand('Set_StartPoint', _CommandSetStartPoint())
|
||||
# FreeCADGui.addCommand('Set_EndPoint', _CommandSetEndPoint())
|
||||
FreeCADGui.addCommand('Set_StartPoint', _CommandSetStartPoint())
|
||||
FreeCADGui.addCommand('Set_EndPoint', _CommandSetEndPoint())
|
||||
|
||||
FreeCAD.Console.PrintLog("Loading PathProfileEdges... done\n")
|
||||
|
||||
@@ -442,19 +442,19 @@ class TaskPanel:
|
||||
|
||||
def getFields(self):
|
||||
if self.obj:
|
||||
if hasattr(self.obj, "StartDepth"):
|
||||
self.obj.StartDepth = self.form.startDepth.text()
|
||||
if hasattr(self.obj, "FinalDepth"):
|
||||
self.obj.FinalDepth = self.form.finalDepth.text()
|
||||
if hasattr(self.obj, "FinishDepth"):
|
||||
self.obj.FinishDepth = self.form.finishDepth.text()
|
||||
if hasattr(self.obj, "StepDown"):
|
||||
self.obj.StepDown = self.form.stepDown.value()
|
||||
|
||||
if hasattr(self.obj, "StartDepth"):
|
||||
self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value
|
||||
if hasattr(self.obj, "FinalDepth"):
|
||||
self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value
|
||||
if hasattr(self.obj, "FinishDepth"):
|
||||
self.obj.FinishDepth = FreeCAD.Units.Quantity(self.form.finishDepth.text()).Value
|
||||
if hasattr(self.obj, "StepDown"):
|
||||
self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value
|
||||
if hasattr(self.obj, "SafeHeight"):
|
||||
self.obj.SafeHeight = self.form.safeHeight.text()
|
||||
self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value
|
||||
if hasattr(self.obj, "ClearanceHeight"):
|
||||
self.obj.ClearanceHeight = self.form.clearanceHeight.text()
|
||||
self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value
|
||||
if hasattr(self.obj, "Algorithm"):
|
||||
self.obj.Algorithm = str(
|
||||
self.form.algorithmSelect.currentText())
|
||||
@@ -462,13 +462,12 @@ class TaskPanel:
|
||||
self.obj.Proxy.execute(self.obj)
|
||||
|
||||
def setFields(self):
|
||||
self.form.startDepth.setText(str(self.obj.StartDepth.Value))
|
||||
self.form.finalDepth.setText(str(self.obj.FinalDepth.Value))
|
||||
self.form.finishDepth.setText(str(self.obj.FinishDepth.Value))
|
||||
self.form.stepDown.setValue(self.obj.StepDown)
|
||||
|
||||
self.form.safeHeight.setText(str(self.obj.SafeHeight.Value))
|
||||
self.form.clearanceHeight.setText(str(self.obj.ClearanceHeight.Value))
|
||||
self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.finishDepth.setText(FreeCAD.Units.Quantity(self.obj.FinishDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown, FreeCAD.Units.Length).UserString)
|
||||
self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
|
||||
for i in self.obj.Base:
|
||||
self.form.baseList.addItem(i[0].Name)
|
||||
|
||||
@@ -35,6 +35,7 @@ from DraftGeomUtils import geomType
|
||||
import PathScripts
|
||||
from PathScripts import PathJob
|
||||
# import itertools
|
||||
import numpy
|
||||
|
||||
def cleanedges(splines, precision):
|
||||
'''cleanedges([splines],precision). Convert BSpline curves, Beziers, to arcs that can be used for cnc paths.
|
||||
@@ -840,27 +841,53 @@ class depth_params:
|
||||
'''returns a list of depths to be used in order from first to last.
|
||||
equalstep=True: all steps down before the finish pass will be equalized.'''
|
||||
|
||||
depths = []
|
||||
if self.user_depths is not None:
|
||||
depths = self.user_depths
|
||||
else:
|
||||
total_depth = self.start_depth - self.final_depth
|
||||
if total_depth <= 0:
|
||||
return depths
|
||||
layers_required = int((total_depth - self.z_finish_step) / self.step_down)
|
||||
partial_steplayer = (total_depth - self.z_finish_step) % self.step_down
|
||||
if equalstep is True and partial_steplayer > 0:
|
||||
layerstep = float((total_depth - self.z_finish_step) / (layers_required + 1))
|
||||
return self.user_depths
|
||||
|
||||
total_depth = self.start_depth - self.final_depth
|
||||
|
||||
if total_depth < 0:
|
||||
return []
|
||||
|
||||
depths = [self.final_depth]
|
||||
|
||||
# apply finish step if necessary
|
||||
if self.z_finish_step > 0:
|
||||
if self.z_finish_step < total_depth:
|
||||
depths.append(self.z_finish_step + self.final_depth)
|
||||
else:
|
||||
layerstep = self.step_down
|
||||
return depths
|
||||
|
||||
for step in range(layers_required):
|
||||
d = self.start_depth - ((step +1) * layerstep)
|
||||
depths.append(d)
|
||||
|
||||
if self.z_finish_step != 0 and depths[-1] != self.final_depth + self.z_finish_step:
|
||||
depths.append(self.final_depth + self.z_finish_step)
|
||||
if depths[-1] != self.final_depth:
|
||||
depths.append(self.final_depth)
|
||||
if equalstep:
|
||||
depths += self.__equal_steps(self.start_depth, depths[-1], self.step_down)[1:]
|
||||
else:
|
||||
depths += self.__fixed_steps(self.start_depth, depths[-1], self.step_down)[1:]
|
||||
|
||||
depths.reverse()
|
||||
return depths
|
||||
|
||||
def __equal_steps(self, start, stop, max_size):
|
||||
'''returns a list of depths beginning with the bottom (included), ending
|
||||
with the top (not included).
|
||||
all steps are of equal size, which is as big as possible but not bigger
|
||||
than max_size.'''
|
||||
|
||||
steps_needed = math.ceil((start - stop) / max_size)
|
||||
depths = numpy.linspace(stop, start, steps_needed, endpoint=False)
|
||||
|
||||
return depths.tolist()
|
||||
|
||||
def __fixed_steps(self, start, stop, size):
|
||||
'''returns a list of depths beginning with the bottom (included), ending
|
||||
with the top (not included).
|
||||
all steps are of size 'size' except the one at the bottom wich can be
|
||||
smaller.'''
|
||||
|
||||
fullsteps = int((start - stop) / size)
|
||||
last_step = start - (fullsteps * size)
|
||||
depths = numpy.linspace(last_step, start, fullsteps, endpoint=False)
|
||||
|
||||
if last_step == stop:
|
||||
return depths.tolist()
|
||||
else:
|
||||
return [stop] + depths.tolist()
|
||||
|
||||
Reference in New Issue
Block a user