Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #2276 from Russ4262/profile_faces_fix
Browse files Browse the repository at this point in the history
[Path] fix ProfileFaces limited depth;  fix to remove phantom paths;  proxy improvements
  • Loading branch information
sliptonic committed Jun 20, 2019
2 parents 8be5217 + 165548d commit 12ae0b3
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 72 deletions.
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathAdaptive.py
Expand Up @@ -536,5 +536,5 @@ def Create(name, obj = None):
'''Create(name) ... Creates and returns a Adaptive operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
proxy = PathAdaptive(obj,name)
obj.Proxy = PathAdaptive(obj,name)
return obj
4 changes: 2 additions & 2 deletions src/Mod/Path/PathScripts/PathDrilling.py
Expand Up @@ -135,7 +135,7 @@ def Create(name, obj = None):
'''Create(name) ... Creates and returns a Drilling operation.'''
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
proxy = ObjectDrilling(obj, name)
obj.Proxy = ObjectDrilling(obj, name)
if obj.Proxy:
proxy.findAllHoles(obj)
obj.Proxy.findAllHoles(obj)
return obj
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/PathJob.py
Expand Up @@ -409,6 +409,6 @@ def Create(name, base, templateFile = None):
else:
models = base
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
proxy = ObjectJob(obj, models, templateFile)
obj.Proxy = ObjectJob(obj, models, templateFile)
return obj

4 changes: 4 additions & 0 deletions src/Mod/Path/PathScripts/PathJobGui.py
Expand Up @@ -1060,6 +1060,10 @@ def alignCenterInStockXY(self):
Draft.move(sel.Object, by)

def updateSelection(self):
# Remove Job object if present in Selection: source of phantom paths
if self.obj in FreeCADGui.Selection.getSelection():
FreeCADGui.Selection.removeSelection(self.obj)

sel = FreeCADGui.Selection.getSelectionEx()

if len(sel) == 1 and len(sel[0].SubObjects) == 1:
Expand Down
149 changes: 81 additions & 68 deletions src/Mod/Path/PathScripts/PathProfileFaces.py
Expand Up @@ -48,8 +48,8 @@
__doc__ = "Path Profile operation based on faces."
__contributors__ = "russ4262 (Russell Johnson)"
__created__ = "2014"
__scriptVersion__ = "2g testing"
__lastModified__ = "2019-06-12 23:29 CST"
__scriptVersion__ = "2h testing"
__lastModified__ = "2019-06-18 22:36 CST"

if False:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
Expand Down Expand Up @@ -109,6 +109,8 @@ def areaOpShapes(self, obj):
shapes = []
self.profileshape = []
finalDepths = []
startDepths = []
faceDepths = []

baseSubsTuples = []
subCount = 0
Expand Down Expand Up @@ -179,9 +181,12 @@ def areaOpShapes(self, obj):
baseSubsTuples.append((base, subList, 0.0, 'X', stock))

# for base in obj.Base:
finish_step = obj.FinishDepth.Value if hasattr(obj, "FinishDepth") else 0.0
for (base, subsList, angle, axis, stock) in baseSubsTuples:
holes = []
faces = []
faceDepths = []
startDepths = []

for sub in subsList:
shape = getattr(base.Shape, sub)
Expand All @@ -190,31 +195,40 @@ def areaOpShapes(self, obj):
if numpy.isclose(abs(shape.normalAt(0, 0).z), 1): # horizontal face
for wire in shape.Wires[1:]:
holes.append((base.Shape, wire))
# Add face depth to list
faceDepths.append(shape.BoundBox.ZMin)
else:
ignoreSub = base.Name + '.' + sub
msg = translate('Path', "Found a selected object which is not a face. Ignoring: {}".format(ignoreSub))
PathLog.error(msg)
FreeCAD.Console.PrintWarning(msg)
# return

# Raise FinalDepth to lowest face in list on Inside profile ops
finDep = obj.FinalDepth.Value
if obj.Side == 'Inside':
finDep = min(faceDepths)
finalDepths.append(finDep)

strDep = obj.StartDepth.Value
if strDep > stock.Shape.BoundBox.ZMax:
strDep = stock.Shape.BoundBox.ZMax
startDepths.append(strDep)

# Recalculate depthparams
self.depthparams = PathUtils.depth_params(
clearance_height=obj.ClearanceHeight.Value,
safe_height=obj.SafeHeight.Value,
start_depth=strDep, # obj.StartDepth.Value,
step_down=obj.StepDown.Value,
z_finish_step=finish_step,
final_depth=finDep, # obj.FinalDepth.Value,
user_depths=None)

for shape, wire in holes:
f = Part.makeFace(wire, 'Part::FaceMakerSimple')
drillable = PathUtils.isDrillable(shape, wire)
if (drillable and obj.processCircles) or (not drillable and obj.processHoles):
PathLog.track()
# Recalculate depthparams
(strDep, finDep) = self.calculateStartFinalDepths(obj, shape, stock)
finalDepths.append(finDep)
PathLog.debug("Adjusted face depths strDep: {}, and finDep: {}".format(self.strDep, self.finDep))
finish_step = obj.FinishDepth.Value if hasattr(obj, "FinishDepth") else 0.0
self.depthparams = PathUtils.depth_params(
clearance_height=obj.ClearanceHeight.Value,
safe_height=obj.SafeHeight.Value,
start_depth=strDep, # obj.StartDepth.Value,
step_down=obj.StepDown.Value,
z_finish_step=finish_step,
final_depth=finDep, # obj.FinalDepth.Value,
user_depths=None)
env = PathUtils.getEnvelope(shape, subshape=f, depthparams=self.depthparams)
# shapes.append((env, True))
tup = env, True, 'pathProfileFaces', angle, axis, strDep, finDep
Expand All @@ -226,23 +240,6 @@ def areaOpShapes(self, obj):

if obj.processPerimeter:
PathLog.track()
if profileshape:
# Recalculate depthparams
(strDep, finDep) = self.calculateStartFinalDepths(obj, profileshape, stock)
finalDepths.append(finDep)
PathLog.debug("Adjusted face depths strDep: {}, and finDep: {}".format(self.strDep, self.finDep))
finish_step = obj.FinishDepth.Value if hasattr(obj, "FinishDepth") else 0.0
self.depthparams = PathUtils.depth_params(
clearance_height=obj.ClearanceHeight.Value,
safe_height=obj.SafeHeight.Value,
start_depth=strDep, # obj.StartDepth.Value,
step_down=obj.StepDown.Value,
z_finish_step=finish_step,
final_depth=finDep, # obj.FinalDepth.Value,
user_depths=None)
else:
strDep = obj.StartDepth.Value
finDep = obj.FinalDepth.Value
try:
env = PathUtils.getEnvelope(base.Shape, subshape=profileshape, depthparams=self.depthparams)
except Exception:
Expand All @@ -254,50 +251,63 @@ def areaOpShapes(self, obj):
shapes.append(tup)
else:
for shape in faces:
finalDep = finDep
# Recalculate depthparams
(strDep, finDep) = self.calculateStartFinalDepths(obj, shape, stock)
finalDepths.append(finDep)
finish_step = obj.FinishDepth.Value if hasattr(obj, "FinishDepth") else 0.0
self.depthparams = PathUtils.depth_params(
clearance_height=obj.ClearanceHeight.Value,
safe_height=obj.SafeHeight.Value,
start_depth=strDep, # obj.StartDepth.Value,
step_down=obj.StepDown.Value,
z_finish_step=finish_step,
final_depth=finDep, # obj.FinalDepth.Value,
user_depths=None)
env = PathUtils.getEnvelope(base.Shape, subshape=shape, depthparams=self.depthparams)
tup = env, False, 'pathProfileFaces', angle, axis, strDep, finDep
if obj.Side == 'Inside':
if finalDep < shape.BoundBox.ZMin:
custDepthparams = PathUtils.depth_params(
clearance_height=obj.ClearanceHeight.Value,
safe_height=obj.SafeHeight.Value,
start_depth=strDep, # obj.StartDepth.Value,
step_down=obj.StepDown.Value,
z_finish_step=finish_step,
final_depth=shape.BoundBox.ZMin, # obj.FinalDepth.Value,
user_depths=None)
env = PathUtils.getEnvelope(base.Shape, subshape=shape, depthparams=custDepthparams)
finalDep = shape.BoundBox.ZMin
else:
env = PathUtils.getEnvelope(base.Shape, subshape=shape, depthparams=self.depthparams)
else:
env = PathUtils.getEnvelope(base.Shape, subshape=shape, depthparams=self.depthparams)
tup = env, False, 'pathProfileFaces', angle, axis, strDep, finalDep
shapes.append(tup)
# Eif

# adjust FinalDepth as needed
finalDepth = min(finalDepths)
if obj.FinalDepth.Value < finalDepth:
obj.FinalDepth.Value = finalDepth
# adjust Start/Final Depths as needed
# Raise existing Final Depth to level of lowest profile face
if obj.Side == 'Inside':
finalDepth = min(finalDepths)
if obj.FinalDepth.Value < finalDepth:
obj.FinalDepth.Value = finalDepth
# Lower high Start Depth to top of Stock
startDepth = max(startDepths)
if obj.StartDepth.Value > startDepth:
obj.StartDepth.Value = startDepth
else: # Try to build targets from the job base
if 1 == len(self.model) and hasattr(self.model[0], "Proxy"):
if isinstance(self.model[0].Proxy, ArchPanel.PanelSheet): # process the sheet
if obj.processCircles or obj.processHoles:
for shape in self.model[0].Proxy.getHoles(self.model[0], transform=True):
for wire in shape.Wires:
drillable = PathUtils.isDrillable(self.model[0].Proxy, wire)
if (drillable and obj.processCircles) or (not drillable and obj.processHoles):
if 1 == len(self.model):
if hasattr(self.model[0], "Proxy"):
PathLog.info("hasattr() Proxy")
if isinstance(self.model[0].Proxy, ArchPanel.PanelSheet): # process the sheet
if obj.processCircles or obj.processHoles:
for shape in self.model[0].Proxy.getHoles(self.model[0], transform=True):
for wire in shape.Wires:
drillable = PathUtils.isDrillable(self.model[0].Proxy, wire)
if (drillable and obj.processCircles) or (not drillable and obj.processHoles):
f = Part.makeFace(wire, 'Part::FaceMakerSimple')
env = PathUtils.getEnvelope(self.model[0].Shape, subshape=f, depthparams=self.depthparams)
# shapes.append((env, True))
tup = env, True, 'pathProfileFaces', 0.0, 'X', obj.StartDepth.Value, obj.FinalDepth.Value
shapes.append(tup)

if obj.processPerimeter:
for shape in self.model[0].Proxy.getOutlines(self.model[0], transform=True):
for wire in shape.Wires:
f = Part.makeFace(wire, 'Part::FaceMakerSimple')
env = PathUtils.getEnvelope(self.model[0].Shape, subshape=f, depthparams=self.depthparams)
# shapes.append((env, True))
tup = env, True, 'pathProfileFaces', 0.0, 'X', obj.StartDepth.Value, obj.FinalDepth.Value
# shapes.append((env, False))
tup = env, False, 'pathProfileFaces', 0.0, 'X', obj.StartDepth.Value, obj.FinalDepth.Value
shapes.append(tup)

if obj.processPerimeter:
for shape in self.model[0].Proxy.getOutlines(self.model[0], transform=True):
for wire in shape.Wires:
f = Part.makeFace(wire, 'Part::FaceMakerSimple')
env = PathUtils.getEnvelope(self.model[0].Shape, subshape=f, depthparams=self.depthparams)
# shapes.append((env, False))
tup = env, False, 'pathProfileFaces', 0.0, 'X', obj.StartDepth.Value, obj.FinalDepth.Value
shapes.append(tup)

self.removalshapes = shapes
PathLog.debug("%d shapes" % len(shapes))

Expand All @@ -315,6 +325,9 @@ def areaOpSetDefaultValues(self, obj, job):
obj.AttemptInverseAngle = True
obj.B_AxisErrorOverride = False

def checkDepths(self, obj, shape):
return (strDept, finDep)


def SetupProperties():
setup = PathProfileBase.SetupProperties()
Expand Down

0 comments on commit 12ae0b3

Please sign in to comment.