Skip to content

Commit

Permalink
Merge pull request #3545 from Russ4262/Multi-profile
Browse files Browse the repository at this point in the history
[Path] Profile - New `ExpandProfile` feature for compound profile operations
  • Loading branch information
sliptonic committed Jun 19, 2020
2 parents 2962110 + 521b0e4 commit 7aa20e8
Show file tree
Hide file tree
Showing 3 changed files with 322 additions and 140 deletions.
80 changes: 44 additions & 36 deletions src/Mod/Path/PathScripts/PathAreaOp.py
Expand Up @@ -29,14 +29,13 @@
import PathScripts.PathUtils as PathUtils
import PathScripts.PathGeom as PathGeom
import math
from PySide import QtCore

# lazily loaded modules
from lazy_loader.lazy_loader import LazyLoader
Draft = LazyLoader('Draft', globals(), 'Draft')
Part = LazyLoader('Part', globals(), 'Part')

# from PathScripts.PathUtils import waiting_effects
from PySide import QtCore
if FreeCAD.GuiUp:
import FreeCADGui

Expand Down Expand Up @@ -234,6 +233,8 @@ def _buildPathArea(self, obj, baseobject, isHole, start, getsim):
area.add(baseobject)

areaParams = self.areaOpAreaParams(obj, isHole) # pylint: disable=assignment-from-no-return
if hasattr(obj, 'ExpandProfile') and obj.ExpandProfile != 0:
areaParams = self.areaOpAreaParamsExpandProfile(obj, isHole) # pylint: disable=assignment-from-no-return

heights = [i for i in self.depthparams]
PathLog.debug('depths: {}'.format(heights))
Expand Down Expand Up @@ -283,8 +284,8 @@ def _buildPathArea(self, obj, baseobject, isHole, start, getsim):

return pp, simobj

def _buildProfileOpenEdges(self, obj, baseShape, isHole, start, getsim):
'''_buildPathArea(obj, baseShape, isHole, start, getsim) ... internal function.'''
def _buildProfileOpenEdges(self, obj, edgeList, isHole, start, getsim):
'''_buildPathArea(obj, edgeList, isHole, start, getsim) ... internal function.'''
# pylint: disable=unused-argument
PathLog.track()

Expand All @@ -293,35 +294,36 @@ def _buildProfileOpenEdges(self, obj, baseShape, isHole, start, getsim):
PathLog.debug('depths: {}'.format(heights))
lstIdx = len(heights) - 1
for i in range(0, len(heights)):
hWire = Part.Wire(Part.__sortEdges__(baseShape.Edges))
hWire.translate(FreeCAD.Vector(0, 0, heights[i] - hWire.BoundBox.ZMin))

pathParams = {} # pylint: disable=assignment-from-no-return
pathParams['shapes'] = [hWire]
pathParams['feedrate'] = self.horizFeed
pathParams['feedrate_v'] = self.vertFeed
pathParams['verbose'] = True
pathParams['resume_height'] = obj.SafeHeight.Value
pathParams['retraction'] = obj.ClearanceHeight.Value
pathParams['return_end'] = True
# Note that emitting preambles between moves breaks some dressups and prevents path optimization on some controllers
pathParams['preamble'] = False

if self.endVector is None:
V = hWire.Wires[0].Vertexes
lv = len(V) - 1
pathParams['start'] = FreeCAD.Vector(V[0].X, V[0].Y, V[0].Z)
if obj.Direction == 'CCW':
pathParams['start'] = FreeCAD.Vector(V[lv].X, V[lv].Y, V[lv].Z)
else:
pathParams['start'] = self.endVector
for baseShape in edgeList:
hWire = Part.Wire(Part.__sortEdges__(baseShape.Edges))
hWire.translate(FreeCAD.Vector(0, 0, heights[i] - hWire.BoundBox.ZMin))

pathParams = {} # pylint: disable=assignment-from-no-return
pathParams['shapes'] = [hWire]
pathParams['feedrate'] = self.horizFeed
pathParams['feedrate_v'] = self.vertFeed
pathParams['verbose'] = True
pathParams['resume_height'] = obj.SafeHeight.Value
pathParams['retraction'] = obj.ClearanceHeight.Value
pathParams['return_end'] = True
# Note that emitting preambles between moves breaks some dressups and prevents path optimization on some controllers
pathParams['preamble'] = False

if self.endVector is None:
V = hWire.Wires[0].Vertexes
lv = len(V) - 1
pathParams['start'] = FreeCAD.Vector(V[0].X, V[0].Y, V[0].Z)
if obj.Direction == 'CCW':
pathParams['start'] = FreeCAD.Vector(V[lv].X, V[lv].Y, V[lv].Z)
else:
pathParams['start'] = self.endVector

obj.PathParams = str({key: value for key, value in pathParams.items() if key != 'shapes'})
PathLog.debug("Path with params: {}".format(obj.PathParams))
obj.PathParams = str({key: value for key, value in pathParams.items() if key != 'shapes'})
PathLog.debug("Path with params: {}".format(obj.PathParams))

(pp, end_vector) = Path.fromShapes(**pathParams)
paths.extend(pp.Commands)
PathLog.debug('pp: {}, end vector: {}'.format(pp, end_vector))
(pp, end_vector) = Path.fromShapes(**pathParams)
paths.extend(pp.Commands)
PathLog.debug('pp: {}, end vector: {}'.format(pp, end_vector))

self.endVector = end_vector # pylint: disable=attribute-defined-outside-init

Expand Down Expand Up @@ -410,11 +412,17 @@ def opExecute(self, obj, getsim=False): # pylint: disable=arguments-differ
shapes.append(shp)

if len(shapes) > 1:
jobs = [{
'x': s[0].BoundBox.XMax,
'y': s[0].BoundBox.YMax,
'shape': s
} for s in shapes]
jobs = list()
for s in shapes:
if s[2] == 'OpenEdge':
shp = Part.makeCompound(s[0])
else:
shp = s[0]
jobs.append({
'x': shp.BoundBox.XMax,
'y': shp.BoundBox.YMax,
'shape': s
})

jobs = PathUtils.sort_jobs(jobs, ['x', 'y'])

Expand Down

0 comments on commit 7aa20e8

Please sign in to comment.