Basic pocket generation from horizontal faces.
This commit is contained in:
@@ -229,6 +229,7 @@ class ObjectOp(object):
|
||||
It also sets the following instance variables that can and should be safely be used by
|
||||
implementation of opExecute():
|
||||
self.baseobject ... Base object of the Job itself
|
||||
self.stock ... Stock object fo the Job itself
|
||||
self.vertFeed ... vertical feed rate of assigned tool
|
||||
self.vertRapid ... vertical rapid rate of assigned tool
|
||||
self.horizFeed ... horizontal feed rate of assigned tool
|
||||
@@ -259,6 +260,7 @@ class ObjectOp(object):
|
||||
PathLog.error(translate("Path", "Parent job %s doesn't have a base object") % job.Label)
|
||||
return
|
||||
self.baseobject = job.Base
|
||||
self.stock = job.Stock
|
||||
|
||||
if FeatureTool & self.opFeatures(obj):
|
||||
tc = obj.ToolController
|
||||
|
||||
@@ -28,6 +28,7 @@ import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathOp as PathOp
|
||||
import PathScripts.PathPocketBase as PathPocketBase
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import TechDraw
|
||||
import sys
|
||||
|
||||
from PathScripts.PathGeom import PathGeom
|
||||
@@ -38,7 +39,7 @@ __author__ = "sliptonic (Brad Collette)"
|
||||
__url__ = "http://www.freecadweb.org"
|
||||
__doc__ = "Class and implementation of shape based Pocket operation."
|
||||
|
||||
if False:
|
||||
if True:
|
||||
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
|
||||
PathLog.trackModule(PathLog.thisModule())
|
||||
else:
|
||||
@@ -66,24 +67,28 @@ class ObjectPocket(PathPocketBase.ObjectPocket):
|
||||
if obj.Base:
|
||||
PathLog.debug("base items exist. Processing...")
|
||||
removalshapes = []
|
||||
for b in obj.Base:
|
||||
PathLog.debug("Base item: {}".format(b))
|
||||
for sub in b[1]:
|
||||
horizontal = []
|
||||
for o in obj.Base:
|
||||
PathLog.debug("Base item: {}".format(o))
|
||||
base = o[0]
|
||||
for sub in o[1]:
|
||||
if "Face" in sub:
|
||||
shape = Part.makeCompound([getattr(b[0].Shape, sub)])
|
||||
else:
|
||||
edges = [getattr(b[0].Shape, sub) for sub in b[1]]
|
||||
shape = Part.makeFace(edges, 'Part::FaceMakerSimple')
|
||||
face = base.Shape.getElement(sub)
|
||||
if type(face.Surface) == Part.Plane and PathGeom.pointsCoincide(face.Surface.Axis, FreeCAD.Vector(0, 0, 1)):
|
||||
horizontal.append(face)
|
||||
|
||||
for face in horizontal:
|
||||
face.translate(FreeCAD.Vector(0, 0, obj.FinalDepth.Value - face.BoundBox.ZMin))
|
||||
removalshapes.append((face.extrude(FreeCAD.Vector(0, 0, obj.StartDepth.Value - obj.FinalDepth.Value)), False))
|
||||
|
||||
env = PathUtils.getEnvelope(self.baseobject.Shape, subshape=shape, depthparams=self.depthparams)
|
||||
obj.removalshape = env.cut(self.baseobject.Shape)
|
||||
obj.removalshape.tessellate(0.1)
|
||||
removalshapes.append((obj.removalshape, False))
|
||||
else: # process the job base object as a whole
|
||||
PathLog.debug("processing the whole job base object")
|
||||
self.outline = Part.Face(TechDraw.findShapeOutline(self.baseobject.Shape, 1, FreeCAD.Vector(0, 0, 1)))
|
||||
stockBB = self.stock.Shape.BoundBox
|
||||
|
||||
env = PathUtils.getEnvelope(self.baseobject.Shape, subshape=None, depthparams=self.depthparams)
|
||||
obj.removalshape = env.cut(self.baseobject.Shape)
|
||||
self.outline.translate(FreeCAD.Vector(0, 0, stockBB.ZMin - 1))
|
||||
self.body = self.outline.extrude(FreeCAD.Vector(0, 0, stockBB.ZLength + 2))
|
||||
obj.removalshape = self.stock.Shape.cut(self.body)
|
||||
obj.removalshape.tessellate(0.1)
|
||||
removalshapes = [(obj.removalshape, False)]
|
||||
return removalshapes
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
import FreeCAD
|
||||
import PathScripts.PathOpGui as PathOpGui
|
||||
import PathScripts.PathPocket as PathPocket
|
||||
import PathScripts.PathPocketShape as PathPocketShape
|
||||
import PathScripts.PathPocketBaseGui as PathPocketBaseGui
|
||||
|
||||
from PySide import QtCore
|
||||
@@ -42,7 +42,7 @@ class TaskPanelOpPage(PathPocketBaseGui.TaskPanelOpPage):
|
||||
return PathPocketBaseGui.FeaturePocket
|
||||
|
||||
Command = PathOpGui.SetupOperation('Pocket Shape',
|
||||
PathPocket.Create,
|
||||
PathPocketShape.Create,
|
||||
TaskPanelOpPage,
|
||||
'Path-Pocket',
|
||||
QtCore.QT_TRANSLATE_NOOP("PathPocket", "Pocket Shape"),
|
||||
|
||||
Reference in New Issue
Block a user