From e790963a45316e7b9c7182f1d78ca1bb071051b7 Mon Sep 17 00:00:00 2001 From: sliptonic Date: Sat, 6 Aug 2016 14:49:51 -0500 Subject: [PATCH] Another attempt at getting pocket output to consistently include feedrate --- src/Mod/Path/PathScripts/PathJob.py | 20 +++++++++++++++++++- src/Mod/Path/PathScripts/PathPocket.py | 20 ++++++++------------ src/Mod/Path/PathScripts/nc/iso.py | 2 +- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathJob.py b/src/Mod/Path/PathScripts/PathJob.py index a352d5a93783..697a9ddcdc62 100644 --- a/src/Mod/Path/PathScripts/PathJob.py +++ b/src/Mod/Path/PathScripts/PathJob.py @@ -26,9 +26,9 @@ import Path from PySide import QtCore, QtGui import os -import sys import glob import PathLoadTool +import Draft FreeCADGui = None @@ -83,6 +83,8 @@ def __init__(self, obj): obj.addProperty("App::PropertyDistance", "Y_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel")) obj.addProperty("App::PropertyDistance", "Z_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel")) + obj.addProperty("App::PropertyLink", "Base", "Base", "The base object for all operations") + obj.Proxy = self if FreeCAD.GuiUp: @@ -236,6 +238,11 @@ def __init__(self): self.form.cboPostProcessor.addItem(post) self.updating = False + self.form.cboBaseObject.addItem("") + for o in FreeCAD.ActiveDocument.Objects: + if hasattr(o, "Shape"): + self.form.cboBaseObject.addItem(o.Name) + def accept(self): self.getFields() @@ -266,6 +273,12 @@ def getFields(self): newlist.append(olditem) self.obj.Group = newlist + objName = self.form.cboBaseObject.currentText() + selObj = FreeCAD.ActiveDocument.getObject(objName) + if self.form.chkCreateClone.isChecked(): + selObj = Draft.clone(selObj) + self.obj.Base = selObj + self.obj.Proxy.execute(self.obj) @@ -282,6 +295,10 @@ def setFields(self): for child in self.obj.Group: self.form.PathsList.addItem(child.Name) + if self.obj.Base is not None: + index = self.form.cboBaseObject.findText(self.obj.Base.Name, QtCore.Qt.MatchFixedString) + if index >= 0: + self.form.cboBaseObject.setCurrentIndex(index) def open(self): @@ -303,6 +320,7 @@ def setupUi(self): self.form.leLabel.editingFinished.connect(self.getFields) self.form.btnSelectFile.clicked.connect(self.setFile) self.form.PathsList.indexesMoved.connect(self.getFields) + self.form.cboBaseObject.currentIndexChanged.connect(self.getFields) self.setFields() diff --git a/src/Mod/Path/PathScripts/PathPocket.py b/src/Mod/Path/PathScripts/PathPocket.py index 0a0d22a1ba4e..539f65553296 100644 --- a/src/Mod/Path/PathScripts/PathPocket.py +++ b/src/Mod/Path/PathScripts/PathPocket.py @@ -197,7 +197,6 @@ def buildpathlibarea(self, obj, a): PathAreaUtils.flush_nc() PathAreaUtils.output('mem') PathAreaUtils.feedrate_hv(self.horizFeed, self.vertFeed) - if obj.UseStartPoint: start_point = (obj.StartPoint.x, obj.StartPoint.y) @@ -216,7 +215,6 @@ def buildpathlibarea(self, obj, a): zig_unidirectional, start_point, cut_mode) - return PathAreaUtils.retrieve_gcode() def buildpathocc(self, obj, shape): @@ -237,9 +235,7 @@ def buildpathocc(self, obj, shape): offsets = [] nextradius = self.radius + extraoffset result = DraftGeomUtils.pocket2d(shape, nextradius) - print "did we get something: " + str(result) while result: - print "Adding " + str(len(result)) + " wires" offsets.extend(result) nextradius += (self.radius * 2) * (float(obj.StepOver)/100) result = DraftGeomUtils.pocket2d(shape, nextradius) @@ -328,7 +324,7 @@ def buildpathocc(self, obj, shape): first = False # then move slow down to our starting point for our profile last = edge.Vertexes[0].Point - output += "G1 X" + fmt(last.x) + " Y" + fmt(last.y) + " Z" + fmt(vpos) + "\n" + output += "G1 X" + fmt(last.x) + " Y" + fmt(last.y) + " Z" + fmt(vpos) + " F" + fmt(self.vertFeed) + "\n" if DraftGeomUtils.geomType(edge) == "Circle": point = edge.Vertexes[-1].Point if point == last: # edges can come flipped @@ -342,14 +338,14 @@ def buildpathocc(self, obj, shape): 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) + output += " I" + fmt(relcenter.x) + " J" + fmt(relcenter.y) + " K" + fmt(relcenter.z) + " F" + fmt(self.horizFeed) output += "\n" last = point else: point = edge.Vertexes[-1].Point if point == last: # edges can come flipped point = edge.Vertexes[0].Point - output += "G1 X" + fmt(point.x) + " Y" + fmt(point.y) + " Z" + fmt(vpos) + "\n" + output += "G1 X" + fmt(point.x) + " Y" + fmt(point.y) + " Z" + fmt(vpos) + " F" + fmt(self.horizFeed) + "\n" last = point # move back up @@ -387,18 +383,14 @@ def execute(self, obj): if obj.Base: for b in obj.Base: for sub in b[1]: - print "object base: " + str(b) import Part import PathScripts.PathKurveUtils if "Face" in sub: - print "inside" shape = getattr(b[0].Shape, sub) wire = shape.OuterWire edges = wire.Edges else: - print "in else" edges = [getattr(b[0].Shape, sub) for sub in b[1]] - print "myedges: " + str(edges) wire = Part.Wire(edges) shape = None @@ -490,7 +482,11 @@ def GetResources(self): 'ToolTip': QtCore.QT_TRANSLATE_NOOP("PathPocket", "Creates a Path Pocket object from a face or faces")} def IsActive(self): - return FreeCAD.ActiveDocument is not None + if FreeCAD.ActiveDocument is not None: + for o in FreeCAD.ActiveDocument.Objects: + if o.Name[:3] == "Job": + return True + return False def Activated(self): diff --git a/src/Mod/Path/PathScripts/nc/iso.py b/src/Mod/Path/PathScripts/nc/iso.py index dc34c2bac1db..645bfb945c25 100644 --- a/src/Mod/Path/PathScripts/nc/iso.py +++ b/src/Mod/Path/PathScripts/nc/iso.py @@ -20,7 +20,7 @@ def __init__(self): self.a = 0 self.b = 0 self.c = 0 - self.f = Address('F', fmt = Format(number_of_decimal_places = 2)) + self.f = Address('F', fmt = Format(number_of_decimal_places = 2), modal = False) self.fh = None self.fv = None self.fhv = False