Added automatic depth calculation into PathOp.execute.

This commit is contained in:
Markus Lampert
2017-09-22 09:48:16 -07:00
parent c2504da3e0
commit 7e16f7fa4a
2 changed files with 58 additions and 46 deletions

View File

@@ -153,52 +153,6 @@ class ObjectPocket(PathPocketBase.ObjectPocket):
obj.FinalDepth = bb.ZMin
obj.StartDepth = bb.ZMax
def areaOpOnChanged(self, obj, prop):
if 'Base' == prop and obj.Base and not 'Restore' in obj.State:
PathLog.track(obj.Label, prop)
zmin = -sys.maxint
zmax = zmin
for base, sublist in obj.Base:
bb = base.Shape.BoundBox # parent boundbox
for sub in sublist:
subobj = base.Shape.getElement(sub)
fbb = subobj.BoundBox # feature boundbox
if fbb.ZMax == fbb.ZMin and fbb.ZMax == bb.ZMax: # top face
finalDepth = bb.ZMin
elif fbb.ZMax > fbb.ZMin and fbb.ZMax == bb.ZMax: # vertical face, full cut
finalDepth = fbb.ZMin
elif fbb.ZMax > fbb.ZMin and fbb.ZMin > bb.ZMin: # internal vertical wall
finalDepth = fbb.ZMin
elif fbb.ZMax == fbb.ZMin and fbb.ZMax > bb.ZMin: # face/shelf
finalDepth = fbb.ZMin
else: # catch all
finalDepth = bb.ZMin
zmin = max(zmin, finalDepth)
zmax = max(zmax, bb.ZMax)
PathLog.debug("%s: final=%.2f, max=%.2f" % (sub, zmin, zmax))
PathLog.debug("zmin=%.2f, zmax=%.2f" % (zmin, zmax))
if not PathGeom.isRoughly(zmin, obj.FinalDepth.Value):
obj.FinalDepth = zmin
if not PathGeom.isRoughly(zmax, obj.StartDepth.Value):
obj.StartDepth = zmax
clearance = zmax + 5.0
safe = zmax + 3
if not PathGeom.isRoughly(clearance, obj.ClearanceHeight.Value):
obj.CearanceHeight = clearance
if not PathGeom.isRoughly(safe, obj.SafeHeight.Value):
obj.SafeHeight = safe
if prop in ['Base', 'Stock'] and not obj.Base and not 'Restore' in obj.State:
job = PathUtils.findParentJob(obj)
if job and job.Stock:
bb = job.Stock.Shape.BoundBox
obj.FinalDepth = bb.ZMin
obj.StartDepth = bb.ZMax
def Create(name):
'''Create(name) ... Creates and returns a Pocket operation.'''
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)