Skip to content

Commit

Permalink
Another attempt at getting pocket output to consistently include feed…
Browse files Browse the repository at this point in the history
…rate
  • Loading branch information
sliptonic authored and yorikvanhavre committed Oct 15, 2016
1 parent bbb7c83 commit e790963
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
20 changes: 19 additions & 1 deletion src/Mod/Path/PathScripts/PathJob.py
Expand Up @@ -26,9 +26,9 @@
import Path
from PySide import QtCore, QtGui
import os
import sys
import glob
import PathLoadTool
import Draft


FreeCADGui = None
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)

Expand All @@ -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):
Expand All @@ -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()

Expand Down
20 changes: 8 additions & 12 deletions src/Mod/Path/PathScripts/PathPocket.py
Expand Up @@ -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)

Expand All @@ -216,7 +215,6 @@ def buildpathlibarea(self, obj, a):
zig_unidirectional,
start_point,
cut_mode)

return PathAreaUtils.retrieve_gcode()

def buildpathocc(self, obj, shape):
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand 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

Expand Down Expand Up @@ -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):

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/nc/iso.py
Expand Up @@ -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
Expand Down

0 comments on commit e790963

Please sign in to comment.