Added support for baseobject into PathOp, used by almost all ops anyway.
This commit is contained in:
committed by
Yorik van Havre
parent
a7edaadcdf
commit
62c9bcc39a
@@ -104,29 +104,24 @@ class ObjectOp(PathOp.ObjectOp):
|
||||
PathLog.track()
|
||||
|
||||
if len(obj.Base) == 0:
|
||||
job = PathUtils.findParentJob(obj)
|
||||
if not job or not job.Base:
|
||||
return
|
||||
baseobject = job.Base
|
||||
|
||||
# Arch PanelSheet
|
||||
features = []
|
||||
if self.baseIsArchPanel(obj, baseobject):
|
||||
holeshapes = baseobject.Proxy.getHoles(baseobject, transform=True)
|
||||
if self.baseIsArchPanel(obj, self.baseobject):
|
||||
holeshapes = self.baseobject.Proxy.getHoles(self.baseobject, transform=True)
|
||||
tooldiameter = obj.ToolController.Proxy.getTool(obj.ToolController).Diameter
|
||||
for holeNr, hole in enumerate(holeshapes):
|
||||
PathLog.debug('Entering new HoleShape')
|
||||
for wireNr, wire in enumerate(hole.Wires):
|
||||
PathLog.debug('Entering new Wire')
|
||||
for edgeNr, edge in enumerate(wire.Edges):
|
||||
if PathUtils.isDrillable(baseobject, edge, tooldiameter):
|
||||
if PathUtils.isDrillable(self.baseobject, edge, tooldiameter):
|
||||
PathLog.debug('Found drillable hole edges: {}'.format(edge))
|
||||
features.append((baseobject, "%d.%d.%d" % (holeNr, wireNr, edgeNr)))
|
||||
features.append((self.baseobject, "%d.%d.%d" % (holeNr, wireNr, edgeNr)))
|
||||
|
||||
self.setDepths(obj, None, None, baseobject.Shape.BoundBox)
|
||||
self.setDepths(obj, None, None, self.baseobject.Shape.BoundBox)
|
||||
else:
|
||||
features = self.findHoles(obj, baseobject)
|
||||
self.setupDepthsFrom(obj, features, baseobject)
|
||||
features = self.findHoles(obj, self.baseobject)
|
||||
self.setupDepthsFrom(obj, features, self.baseobject)
|
||||
obj.Base = features
|
||||
obj.Disabled = []
|
||||
|
||||
|
||||
@@ -145,12 +145,8 @@ class ObjectFace(PathAreaOp.ObjectOp):
|
||||
|
||||
# If no base object, do planing of top surface of entire model
|
||||
else:
|
||||
job = PathUtils.findParentJob(obj)
|
||||
if not job or not job.Base:
|
||||
return
|
||||
baseobject = job.Base
|
||||
planeshape = baseobject.Shape
|
||||
PathLog.debug("Working on a shape {}".format(baseobject.Name))
|
||||
planeshape = self.baseobject.Shape
|
||||
PathLog.debug("Working on a shape {}".format(self.baseobject.Name))
|
||||
|
||||
# if user wants the boundbox, calculate that
|
||||
PathLog.debug("Boundary Shape: {}".format(obj.BoundaryShape))
|
||||
|
||||
@@ -143,6 +143,14 @@ class ObjectOp(object):
|
||||
obj.ViewObject.Visibility = False
|
||||
return
|
||||
|
||||
if not job:
|
||||
PathLog.error(translate("Path", "No parent job found for operation."))
|
||||
return
|
||||
if not job.Base:
|
||||
PathLog.error(translate("Path", "Parent job %s doesn't have a base object") % job.Label)
|
||||
return
|
||||
self.baseobject = job.Base
|
||||
|
||||
if FeatureTool & self.opFeatures(obj):
|
||||
tc = obj.ToolController
|
||||
if tc is None or tc.ToolNumber == 0:
|
||||
|
||||
@@ -96,11 +96,6 @@ class ObjectPocket(PathAreaOp.ObjectOp):
|
||||
def areaOpShapes(self, obj):
|
||||
PathLog.track()
|
||||
|
||||
job = PathUtils.findParentJob(obj)
|
||||
if not job or not job.Base:
|
||||
return
|
||||
baseobject = job.Base
|
||||
|
||||
if obj.Base:
|
||||
PathLog.debug("base items exist. Processing...")
|
||||
removalshapes = []
|
||||
@@ -113,14 +108,14 @@ class ObjectPocket(PathAreaOp.ObjectOp):
|
||||
edges = [getattr(b[0].Shape, sub) for sub in b[1]]
|
||||
shape = Part.makeFace(edges, 'Part::FaceMakerSimple')
|
||||
|
||||
env = PathUtils.getEnvelope(baseobject.Shape, subshape=shape, depthparams=self.depthparams)
|
||||
obj.removalshape = env.cut(baseobject.Shape)
|
||||
env = PathUtils.getEnvelope(self.baseobject.Shape, subshape=shape, depthparams=self.depthparams)
|
||||
obj.removalshape = env.cut(self.baseobject.Shape)
|
||||
removalshapes.append((obj.removalshape, False))
|
||||
else: # process the job base object as a whole
|
||||
PathLog.debug("processing the whole job base object")
|
||||
|
||||
env = PathUtils.getEnvelope(baseobject.Shape, subshape=None, depthparams=self.depthparams)
|
||||
obj.removalshape = env.cut(baseobject.Shape)
|
||||
env = PathUtils.getEnvelope(self.baseobject.Shape, subshape=None, depthparams=self.depthparams)
|
||||
obj.removalshape = env.cut(self.baseobject.Shape)
|
||||
removalshapes = [(obj.removalshape, False)]
|
||||
return removalshapes
|
||||
|
||||
|
||||
@@ -76,27 +76,19 @@ class ObjectContour(PathProfileBase.ObjectProfile):
|
||||
else:
|
||||
self.commandlist.append(Path.Command("(Uncompensated Tool Path)"))
|
||||
|
||||
job = PathUtils.findParentJob(obj)
|
||||
|
||||
if job is None:
|
||||
return
|
||||
baseobject = job.Base
|
||||
if baseobject is None:
|
||||
return
|
||||
|
||||
isPanel = False
|
||||
if hasattr(baseobject, "Proxy"):
|
||||
if isinstance(baseobject.Proxy, ArchPanel.PanelSheet): # process the sheet
|
||||
if hasattr(self.baseobject, "Proxy"):
|
||||
if isinstance(self.baseobject.Proxy, ArchPanel.PanelSheet): # process the sheet
|
||||
isPanel = True
|
||||
baseobject.Proxy.execute(baseobject)
|
||||
shapes = baseobject.Proxy.getOutlines(baseobject, transform=True)
|
||||
self.baseobject.Proxy.execute(self.baseobject)
|
||||
shapes = self.baseobject.Proxy.getOutlines(self.baseobject, transform=True)
|
||||
for shape in shapes:
|
||||
f = Part.makeFace([shape], 'Part::FaceMakerSimple')
|
||||
thickness = baseobject.Group[0].Source.Thickness
|
||||
thickness = self.baseobject.Group[0].Source.Thickness
|
||||
return [(f.extrude(FreeCAD.Vector(0, 0, thickness)), False)]
|
||||
|
||||
if hasattr(baseobject, "Shape") and not isPanel:
|
||||
return [(PathUtils.getEnvelope(partshape=baseobject.Shape, subshape=None, depthparams=self.depthparams), False)]
|
||||
if hasattr(self.baseobject, "Shape") and not isPanel:
|
||||
return [(PathUtils.getEnvelope(partshape=self.baseobject.Shape, subshape=None, depthparams=self.depthparams), False)]
|
||||
|
||||
def areaOpAreaParams(self, obj, isHole):
|
||||
params = self.baseObject().areaOpAreaParams(obj, isHole)
|
||||
|
||||
@@ -69,11 +69,6 @@ class ObjectProfile(PathProfileBase.ObjectProfile):
|
||||
def areaOpShapes(self, obj):
|
||||
PathLog.track()
|
||||
|
||||
job = PathUtils.findParentJob(obj)
|
||||
if not job or not job.Base:
|
||||
return
|
||||
baseobject = job.Base
|
||||
|
||||
if obj.UseComp:
|
||||
self.commandlist.append(Path.Command("(Compensated Tool Path. Diameter: " + str(self.radius * 2) + ")"))
|
||||
else:
|
||||
@@ -97,7 +92,7 @@ class ObjectProfile(PathProfileBase.ObjectProfile):
|
||||
zShift = b[0].Shape.BoundBox.ZMin - f.BoundBox.ZMin
|
||||
newPlace = FreeCAD.Placement(FreeCAD.Vector(0, 0, zShift), f.Placement.Rotation)
|
||||
f.Placement = newPlace
|
||||
env = PathUtils.getEnvelope(baseobject.Shape, subshape=f, depthparams=self.depthparams)
|
||||
env = PathUtils.getEnvelope(self.baseobject.Shape, subshape=f, depthparams=self.depthparams)
|
||||
shapes.append((env, False))
|
||||
return shapes
|
||||
|
||||
|
||||
@@ -79,11 +79,6 @@ class ObjectProfile(PathProfileBase.ObjectProfile):
|
||||
else:
|
||||
self.commandlist.append(Path.Command("(Uncompensated Tool Path)"))
|
||||
|
||||
job = PathUtils.findParentJob(obj)
|
||||
if not job or not job.Base:
|
||||
return
|
||||
|
||||
baseobject = job.Base
|
||||
shapes = []
|
||||
|
||||
if obj.Base: # The user has selected subobjects from the base. Process each.
|
||||
@@ -102,35 +97,35 @@ class ObjectProfile(PathProfileBase.ObjectProfile):
|
||||
|
||||
for wire in holes:
|
||||
f = Part.makeFace(wire, 'Part::FaceMakerSimple')
|
||||
drillable = PathUtils.isDrillable(baseobject.Shape, wire)
|
||||
drillable = PathUtils.isDrillable(self.baseobject.Shape, wire)
|
||||
if (drillable and obj.processCircles) or (not drillable and obj.processHoles):
|
||||
env = PathUtils.getEnvelope(baseobject.Shape, subshape=f, depthparams=self.depthparams)
|
||||
env = PathUtils.getEnvelope(self.baseobject.Shape, subshape=f, depthparams=self.depthparams)
|
||||
shapes.append((env, True))
|
||||
|
||||
if len(faces) > 0:
|
||||
profileshape = Part.makeCompound(faces)
|
||||
|
||||
if obj.processPerimeter:
|
||||
env = PathUtils.getEnvelope(baseobject.Shape, subshape=profileshape, depthparams=self.depthparams)
|
||||
env = PathUtils.getEnvelope(self.baseobject.Shape, subshape=profileshape, depthparams=self.depthparams)
|
||||
shapes.append((env, False))
|
||||
|
||||
else: # Try to build targets from the job base
|
||||
if hasattr(baseobject, "Proxy"):
|
||||
if isinstance(baseobject.Proxy, ArchPanel.PanelSheet): # process the sheet
|
||||
if hasattr(self.baseobject, "Proxy"):
|
||||
if isinstance(self.baseobject.Proxy, ArchPanel.PanelSheet): # process the sheet
|
||||
if obj.processCircles or obj.processHoles:
|
||||
for shape in baseobject.Proxy.getHoles(baseobject, transform=True):
|
||||
for shape in self.baseobject.Proxy.getHoles(self.baseobject, transform=True):
|
||||
for wire in shape.Wires:
|
||||
drillable = PathUtils.isDrillable(baseobject.Proxy, wire)
|
||||
drillable = PathUtils.isDrillable(self.baseobject.Proxy, wire)
|
||||
if (drillable and obj.processCircles) or (not drillable and obj.processHoles):
|
||||
f = Part.makeFace(wire, 'Part::FaceMakerSimple')
|
||||
env = PathUtils.getEnvelope(baseobject.Shape, subshape=f, depthparams=self.depthparams)
|
||||
env = PathUtils.getEnvelope(self.baseobject.Shape, subshape=f, depthparams=self.depthparams)
|
||||
shapes.append((env, True))
|
||||
|
||||
if obj.processPerimeter:
|
||||
for shape in baseobject.Proxy.getOutlines(baseobject, transform=True):
|
||||
for shape in self.baseobject.Proxy.getOutlines(self.baseobject, transform=True):
|
||||
for wire in shape.Wires:
|
||||
f = Part.makeFace(wire, 'Part::FaceMakerSimple')
|
||||
env = PathUtils.getEnvelope(baseobject.Shape, subshape=f, depthparams=self.depthparams)
|
||||
env = PathUtils.getEnvelope(self.baseobject.Shape, subshape=f, depthparams=self.depthparams)
|
||||
shapes.append((env, False))
|
||||
|
||||
return shapes
|
||||
|
||||
Reference in New Issue
Block a user