Fix base geometry reference to use tuple in PropertyLinkSubList
Also improves the naive test of vertical/horizontal faces for profiling.
replace naive test of verticality
Fix base references to use tuple in PropertyLinkSubList
78b92d47b4
This commit is contained in:
parent
d3b69112de
commit
6425ef770d
|
@ -103,57 +103,57 @@ class ObjectDrilling:
|
|||
else:
|
||||
obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")"
|
||||
|
||||
locations = []
|
||||
output = "(Begin Drilling)\n"
|
||||
if obj.Base:
|
||||
locations = []
|
||||
for loc in obj.Base:
|
||||
for sub in loc[1]:
|
||||
|
||||
if "Face" in loc[1] or "Edge" in loc[1]:
|
||||
s = getattr(loc[0].Shape, loc[1])
|
||||
else:
|
||||
s = loc[0].Shape
|
||||
if "Face" in sub or "Edge" in sub:
|
||||
s = getattr(loc[0].Shape, sub)
|
||||
else:
|
||||
s = loc[0].Shape
|
||||
|
||||
if s.ShapeType in ['Wire', 'Edge']:
|
||||
X = s.Edges[0].Curve.Center.x
|
||||
Y = s.Edges[0].Curve.Center.y
|
||||
Z = s.Edges[0].Curve.Center.z
|
||||
elif s.ShapeType in ['Vertex']:
|
||||
X = s.Point.x
|
||||
Y = s.Point.y
|
||||
Z = s.Point.z
|
||||
elif s.ShapeType in ['Face']:
|
||||
#if abs(s.normalAt(0, 0).z) == 1: # horizontal face
|
||||
X = s.CenterOfMass.x
|
||||
Y = s.CenterOfMass.y
|
||||
Z = s.CenterOfMass.z
|
||||
if s.ShapeType in ['Wire', 'Edge']:
|
||||
X = s.Edges[0].Curve.Center.x
|
||||
Y = s.Edges[0].Curve.Center.y
|
||||
Z = s.Edges[0].Curve.Center.z
|
||||
elif s.ShapeType in ['Vertex']:
|
||||
X = s.Point.x
|
||||
Y = s.Point.y
|
||||
Z = s.Point.z
|
||||
elif s.ShapeType in ['Face']:
|
||||
#if abs(s.normalAt(0, 0).z) == 1: # horizontal face
|
||||
X = s.CenterOfMass.x
|
||||
Y = s.CenterOfMass.y
|
||||
Z = s.CenterOfMass.z
|
||||
|
||||
locations.append(FreeCAD.Vector(X, Y, Z))
|
||||
|
||||
|
||||
output += "G90 G98\n"
|
||||
# rapid to clearance height
|
||||
output += "G0 Z" + str(obj.ClearanceHeight.Value)
|
||||
# rapid to first hole location, with spindle still retracted:
|
||||
p0 = locations[0]
|
||||
output += "G0 X" + str(p0.x) + " Y" + str(p0.y) + "\n"
|
||||
# move tool to clearance plane
|
||||
output += "G0 Z" + str(obj.ClearanceHeight.Value) + "\n"
|
||||
if obj.PeckDepth.Value > 0:
|
||||
cmd = "G83"
|
||||
qword = " Q" + str(obj.PeckDepth.Value)
|
||||
else:
|
||||
cmd = "G81"
|
||||
qword = ""
|
||||
for p in locations:
|
||||
output += cmd + \
|
||||
" X" + str(p.x) + \
|
||||
" Y" + str(p.y) + \
|
||||
" Z" + str(obj.FinalDepth.Value) + qword + \
|
||||
" R" + str(obj.RetractHeight.Value) + \
|
||||
" F" + str(self.vertFeed) + "\n" \
|
||||
|
||||
|
||||
locations.append(FreeCAD.Vector(X, Y, Z))
|
||||
|
||||
output = "G90 G98\n"
|
||||
# rapid to clearance height
|
||||
output += "G0 Z" + str(obj.ClearanceHeight.Value)
|
||||
# rapid to first hole location, with spindle still retracted:
|
||||
p0 = locations[0]
|
||||
output += "G0 X" + str(p0.x) + " Y" + str(p0.y) + "\n"
|
||||
# move tool to clearance plane
|
||||
output += "G0 Z" + str(obj.ClearanceHeight.Value) + "\n"
|
||||
if obj.PeckDepth.Value > 0:
|
||||
cmd = "G83"
|
||||
qword = " Q" + str(obj.PeckDepth.Value)
|
||||
else:
|
||||
cmd = "G81"
|
||||
qword = ""
|
||||
for p in locations:
|
||||
output += cmd + \
|
||||
" X" + str(p.x) + \
|
||||
" Y" + str(p.y) + \
|
||||
" Z" + str(obj.FinalDepth.Value) + qword + \
|
||||
" R" + str(obj.RetractHeight.Value) + \
|
||||
" F" + str(self.vertFeed) + "\n" \
|
||||
|
||||
output += "G80\n"
|
||||
output += "G80\n"
|
||||
|
||||
path = Path.Path(output)
|
||||
obj.Path = path
|
||||
|
@ -319,7 +319,8 @@ class TaskPanel:
|
|||
|
||||
self.form.baseList.clear()
|
||||
for i in self.obj.Base:
|
||||
self.form.baseList.addItem(i[0].Name + "." + i[1])
|
||||
for sub in i[1]:
|
||||
self.form.baseList.addItem(i[0].Name + "." + sub)
|
||||
|
||||
|
||||
def open(self):
|
||||
|
@ -341,8 +342,11 @@ class TaskPanel:
|
|||
self.obj.Proxy.addDrillableLocation(self.obj, s.Object)
|
||||
|
||||
self.setFields() # defaults may have changed. Reload.
|
||||
# for i in self.obj.Base:
|
||||
# self.form.baseList.addItem(i[0].Name + "." + i[1])
|
||||
self.form.baseList.clear()
|
||||
|
||||
for i in self.obj.Base:
|
||||
for sub in i[1]:
|
||||
self.form.baseList.addItem(i[0].Name + "." + sub)
|
||||
|
||||
def deleteBase(self):
|
||||
dlist = self.form.baseList.selectedItems()
|
||||
|
|
|
@ -380,59 +380,60 @@ class ObjectPocket:
|
|||
|
||||
if obj.Base:
|
||||
for b in obj.Base:
|
||||
print "object base: " + str(b)
|
||||
import Part
|
||||
import PathScripts.PathKurveUtils
|
||||
if "Face" in b[1]:
|
||||
print "inside"
|
||||
shape = getattr(b[0].Shape, b[1])
|
||||
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
|
||||
|
||||
# output = ""
|
||||
if obj.Algorithm == "OCC Native":
|
||||
if shape is None:
|
||||
shape = wire
|
||||
output += self.buildpathocc(obj, shape)
|
||||
else:
|
||||
try:
|
||||
import area
|
||||
except:
|
||||
FreeCAD.Console.PrintError(translate("PathKurve", "libarea needs to be installed for this command to work.\n"))
|
||||
return
|
||||
|
||||
a = area.Area()
|
||||
if shape is None:
|
||||
c = PathScripts.PathKurveUtils.makeAreaCurve(wire.Edges, 'CW')
|
||||
a.append(c)
|
||||
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:
|
||||
for w in shape.Wires:
|
||||
c = PathScripts.PathKurveUtils.makeAreaCurve(w.Edges, 'CW')
|
||||
# if w.isSame(shape.OuterWire):
|
||||
# print "outerwire"
|
||||
# if c.IsClockwise():
|
||||
# c.Reverse()
|
||||
# print "reverse outterwire"
|
||||
# else:
|
||||
# print "inner wire"
|
||||
# if not c.IsClockwise():
|
||||
# c.Reverse()
|
||||
# print "reverse inner"
|
||||
print "in else"
|
||||
edges = [getattr(b[0].Shape, sub) for sub in b[1]]
|
||||
print "myedges: " + str(edges)
|
||||
wire = Part.Wire(edges)
|
||||
shape = None
|
||||
|
||||
# output = ""
|
||||
if obj.Algorithm == "OCC Native":
|
||||
if shape is None:
|
||||
shape = wire
|
||||
output += self.buildpathocc(obj, shape)
|
||||
else:
|
||||
try:
|
||||
import area
|
||||
except:
|
||||
FreeCAD.Console.PrintError(translate("PathKurve", "libarea needs to be installed for this command to work.\n"))
|
||||
return
|
||||
|
||||
a = area.Area()
|
||||
if shape is None:
|
||||
c = PathScripts.PathKurveUtils.makeAreaCurve(wire.Edges, 'CW')
|
||||
a.append(c)
|
||||
else:
|
||||
for w in shape.Wires:
|
||||
c = PathScripts.PathKurveUtils.makeAreaCurve(w.Edges, 'CW')
|
||||
# if w.isSame(shape.OuterWire):
|
||||
# print "outerwire"
|
||||
# if c.IsClockwise():
|
||||
# c.Reverse()
|
||||
# print "reverse outterwire"
|
||||
# else:
|
||||
# print "inner wire"
|
||||
# if not c.IsClockwise():
|
||||
# c.Reverse()
|
||||
# print "reverse inner"
|
||||
a.append(c)
|
||||
|
||||
########
|
||||
# This puts out some interesting information from libarea
|
||||
print a.text()
|
||||
########
|
||||
########
|
||||
# This puts out some interesting information from libarea
|
||||
print a.text()
|
||||
########
|
||||
|
||||
a.Reorder()
|
||||
output += self.buildpathlibarea(obj, a)
|
||||
a.Reorder()
|
||||
output += self.buildpathlibarea(obj, a)
|
||||
|
||||
if obj.Active:
|
||||
path = Path.Path(output)
|
||||
|
@ -598,8 +599,12 @@ class TaskPanel:
|
|||
if index >= 0:
|
||||
self.form.algorithmSelect.setCurrentIndex(index)
|
||||
|
||||
# for i in self.obj.Base:
|
||||
# self.form.baseList.addItem(i[0].Name + "." + i[1][0])
|
||||
|
||||
for i in self.obj.Base:
|
||||
self.form.baseList.addItem(i[0].Name + "." + i[1])
|
||||
for sub in i[1]:
|
||||
self.form.baseList.addItem(i[0].Name + "." + sub)
|
||||
|
||||
|
||||
|
||||
|
@ -628,8 +633,13 @@ class TaskPanel:
|
|||
|
||||
self.setFields() # defaults may have changed. Reload.
|
||||
self.form.baseList.clear()
|
||||
|
||||
for i in self.obj.Base:
|
||||
self.form.baseList.addItem(i[0].Name + "." + i[1])
|
||||
for sub in i[1]:
|
||||
self.form.baseList.addItem(i[0].Name + "." + sub)
|
||||
|
||||
# for i in self.obj.Base:
|
||||
# self.form.baseList.addItem(i[0].Name + "." + i[1][0])
|
||||
|
||||
def deleteBase(self):
|
||||
dlist = self.form.baseList.selectedItems()
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
import FreeCAD
|
||||
import Path
|
||||
import numpy
|
||||
from FreeCAD import Vector
|
||||
from PathScripts import PathUtils
|
||||
from PathScripts.PathUtils import depth_params
|
||||
|
@ -290,15 +291,18 @@ print "y - " + str(point.y)
|
|||
wires = []
|
||||
|
||||
for b in obj.Base:
|
||||
# we only consider the outer wire if this is a Face
|
||||
# Horizontal and vertical faces are handled differently
|
||||
shape = getattr(b[0].Shape, b[1])
|
||||
if abs(shape.normalAt(0, 0).z) == 1: # horizontal face
|
||||
hfaces.append(shape)
|
||||
|
||||
elif abs(shape.normalAt(0, 0).z) == 0: # vertical face
|
||||
vfaces.append(shape)
|
||||
for sub in b[1]:
|
||||
# we only consider the outer wire if this is a Face
|
||||
# Horizontal and vertical faces are handled differently
|
||||
shape = getattr(b[0].Shape, sub)
|
||||
if numpy.isclose(shape.normalAt(0, 0).z, 1): # horizontal face
|
||||
hfaces.append(shape)
|
||||
|
||||
elif numpy.isclose(shape.normalAt(0, 0).z, 0): # vertical face
|
||||
vfaces.append(shape)
|
||||
else:
|
||||
FreeCAD.Console.PrintError(translate("Path", "Face doesn't appear to be parallel or perpendicular to the XY plane. No path will be generated for: \n"))
|
||||
FreeCAD.Console.PrintError(b[0].Name + "." + sub + "\n")
|
||||
for h in hfaces:
|
||||
wires.append(h.OuterWire)
|
||||
|
||||
|
@ -443,9 +447,6 @@ class CommandPathProfile:
|
|||
return FreeCAD.ActiveDocument is not None
|
||||
|
||||
def Activated(self):
|
||||
# import Path
|
||||
# from PathScripts import PathProject, PathUtils, PathKurveUtils
|
||||
|
||||
ztop = 10.0
|
||||
zbottom = 0.0
|
||||
|
||||
|
@ -553,7 +554,8 @@ class TaskPanel:
|
|||
self.form.direction.setCurrentIndex(index)
|
||||
|
||||
for i in self.obj.Base:
|
||||
self.form.baseList.addItem(i[0].Name + "." + i[1])
|
||||
for sub in i[1]:
|
||||
self.form.baseList.addItem(i[0].Name + "." + sub)
|
||||
|
||||
for i in range(len(self.obj.locs)):
|
||||
item = QtGui.QTreeWidgetItem(self.form.tagTree)
|
||||
|
@ -586,15 +588,16 @@ class TaskPanel:
|
|||
FreeCAD.Console.PrintError(translate("PathProject", "Please select faces from one solid\n"))
|
||||
return
|
||||
|
||||
# if s.HasSubObjects:
|
||||
for i in sel.SubElementNames:
|
||||
self.obj.Proxy.addprofilebase(self.obj, sel.Object, i)
|
||||
#else:
|
||||
#self.obj.Proxy.addprofilebase(self.obj, s.Object)
|
||||
|
||||
self.setFields() # defaults may have changed. Reload.
|
||||
self.form.baseList.clear()
|
||||
|
||||
for i in self.obj.Base:
|
||||
self.form.baseList.addItem(i[0].Name + "." + i[1])
|
||||
for sub in i[1]:
|
||||
self.form.baseList.addItem(i[0].Name + "." + sub)
|
||||
|
||||
|
||||
def deleteBase(self):
|
||||
dlist = self.form.baseList.selectedItems()
|
||||
|
|
Loading…
Reference in New Issue
Block a user