From 07ae0e56c4d48146ee52ee01add7ee9b94b74b25 Mon Sep 17 00:00:00 2001 From: sliptonic Date: Wed, 24 Jan 2018 13:02:45 -0600 Subject: [PATCH] Path: Fix MillFace default values fixes #3324 --- src/Mod/Path/PathScripts/PathMillFace.py | 40 ++++++++++++++----- src/Mod/Path/PathScripts/PathOp.py | 6 ++- .../Path/PathScripts/PathProfileContour.py | 6 +++ 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathMillFace.py b/src/Mod/Path/PathScripts/PathMillFace.py index c86e011e9a..7b671bbb07 100644 --- a/src/Mod/Path/PathScripts/PathMillFace.py +++ b/src/Mod/Path/PathScripts/PathMillFace.py @@ -49,6 +49,7 @@ else: def translate(context, text, disambig=None): return QtCore.QCoreApplication.translate(context, text, disambig) + class ObjectFace(PathPocketBase.ObjectPocket): '''Proxy object for Mill Facing operation.''' @@ -67,12 +68,25 @@ class ObjectFace(PathPocketBase.ObjectPocket): obj.StepOver = 1 # default depths calculation not correct for facing - if prop == "Base" and len(obj.Base) == 1: - base, sub = obj.Base[0] - shape = base.Shape.getElement(sub[0]) - d = PathUtils.guessDepths(shape, None) - obj.OpStartDepth = d.safe_height - obj.OpFinalDepth = d.start_depth + if prop == "Base": + job = PathUtils.findParentJob(obj) + obj.OpStartDepth = job.Stock.Shape.BoundBox.ZMax + + if len(obj.Base) >= 1: + print ('processing') + sublist = [] + for i in obj.Base: + o = i[0] + for s in i[1]: + sublist.append(o.Shape.getElement(s)) + + # If the operation has a geometry identified the Finaldepth + # is the top of the bboundbox which includes all features. + # Otherwise, top of part. + + obj.OpFinalDepth = Part.makeCompound(sublist).BoundBox.ZMax + else: + obj.OpFinalDepth = job.Base.Shape.BoundBox.ZMax def areaOpShapes(self, obj): '''areaOpShapes(obj) ... return top face''' @@ -112,12 +126,18 @@ class ObjectFace(PathPocketBase.ObjectPocket): obj.StepOver = 50 obj.ZigZagAngle = 45.0 - # need to overwrite the default depth calculations for facing job = PathUtils.findParentJob(obj) + + # need to overwrite the default depth calculations for facing if job and job.Base: - d = PathUtils.guessDepths(job.Base.Shape, None) - obj.OpStartDepth = d.safe_height - obj.OpFinalDepth = d.start_depth + obj.OpStartDepth = job.Stock.Shape.BoundBox.ZMax + obj.OpFinalDepth = job.Base.Shape.BoundBox.ZMax + + # If the operation has a geometry identified the Finaldepth + # is the top of the bboundbox which includes all features. + if len(obj.Base) >= 1: + obj.OpFinalDepth = Part.makeCompound(obj.Base).BoundBox.ZMax + def Create(name): '''Create(name) ... Creates and returns a Mill Facing operation.''' diff --git a/src/Mod/Path/PathScripts/PathOp.py b/src/Mod/Path/PathScripts/PathOp.py index 214d64bc2c..a68fbcf7e2 100644 --- a/src/Mod/Path/PathScripts/PathOp.py +++ b/src/Mod/Path/PathScripts/PathOp.py @@ -305,7 +305,7 @@ class ObjectOp(object): def faceZmin(bb, fbb): if fbb.ZMax == fbb.ZMin and fbb.ZMax == bb.ZMax: # top face - return bb.ZMin + return fbb.ZMin elif fbb.ZMax > fbb.ZMin and fbb.ZMax == bb.ZMax: # vertical face, full cut return fbb.ZMin elif fbb.ZMax > fbb.ZMin and fbb.ZMin > bb.ZMin: # internal vertical wall @@ -331,7 +331,9 @@ class ObjectOp(object): zmax = max(zmax, fbb.ZMax) else: # clearing with stock boundaries - pass + job = PathUtils.findParentJob(obj) + zmax = stockBB.ZMax + zmin = job.Base.Shape.BoundBox.ZMax if FeatureDepths & self.opFeatures(obj): # first set update final depth, it's value is not negotiable diff --git a/src/Mod/Path/PathScripts/PathProfileContour.py b/src/Mod/Path/PathScripts/PathProfileContour.py index 9e9e842ba5..5cea86f83c 100644 --- a/src/Mod/Path/PathScripts/PathProfileContour.py +++ b/src/Mod/Path/PathScripts/PathProfileContour.py @@ -101,6 +101,12 @@ class ObjectContour(PathProfileBase.ObjectProfile): params['Coplanar'] = 2 return params + def updateDepths(self, obj, ignoreErrors=False): + stockBB = self.stock.Shape.BoundBox + obj.OpFinalDepth = stockBB.ZMin + obj.OpStartDepth = stockBB.ZMax + + def Create(name): '''Create(name) ... Creates and returns a Contour operation.''' obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)