Added automatic depth calculation into PathOp.execute.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user