Skip to content

Commit

Permalink
Added option to clear edges on PathMillFace
Browse files Browse the repository at this point in the history
Changed debug level
  • Loading branch information
Schildkroet committed Jan 29, 2020
1 parent 4142fb9 commit 3ce47af
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/Mod/Path/PathScripts/PathMillFace.py
Expand Up @@ -59,6 +59,7 @@ def initPocketOp(self, obj):
'''initPocketOp(obj) ... create facing specific properties'''
obj.addProperty("App::PropertyEnumeration", "BoundaryShape", "Face", QtCore.QT_TRANSLATE_NOOP("App::Property", "Shape to use for calculating Boundary"))
obj.BoundaryShape = ['Perimeter', 'Boundbox', 'Stock']
obj.addProperty("App::PropertyBool", "ClearEdges", "Face", QtCore.QT_TRANSLATE_NOOP("App::Property", "Clear edges"))

if not hasattr(obj, 'ExcludeRaisedAreas'):
obj.addProperty("App::PropertyBool", "ExcludeRaisedAreas", "Face", QtCore.QT_TRANSLATE_NOOP("App::Property", "Exclude milling raised areas inside the face."))
Expand Down Expand Up @@ -98,7 +99,7 @@ def areaOpShapes(self, obj):
'''areaOpShapes(obj) ... return top face'''
# Facing is done either against base objects
holeShape = None

if obj.Base:
PathLog.debug("obj.Base: {}".format(obj.Base))
faces = []
Expand Down Expand Up @@ -146,6 +147,17 @@ def areaOpShapes(self, obj):
# Find the correct shape depending on Boundary shape.
PathLog.debug("Boundary Shape: {}".format(obj.BoundaryShape))
bb = planeshape.BoundBox

# Apply offset for clearing edges
offset = 0;
if obj.ClearEdges == True:
offset = self.radius + 0.1

bb.XMin = bb.XMin - offset
bb.YMin = bb.YMin - offset
bb.XMax = bb.XMax + offset
bb.YMax = bb.YMax + offset

if obj.BoundaryShape == 'Boundbox':
bbperim = Part.makeBox(bb.XLength, bb.YLength, 1, FreeCAD.Vector(bb.XMin, bb.YMin, bb.ZMin), FreeCAD.Vector(0, 0, 1))
env = PathUtils.getEnvelope(partshape=bbperim, depthparams=self.depthparams)
Expand All @@ -158,6 +170,7 @@ def areaOpShapes(self, obj):
elif obj.BoundaryShape == 'Stock':
stock = PathUtils.findParentJob(obj).Stock.Shape
env = stock

if obj.ExcludeRaisedAreas is True and oneBase[1] is True:
includedFaces = self.getAllIncludedFaces(oneBase[0], stock, faceZ=minHeight)
if len(includedFaces) > 0:
Expand All @@ -181,6 +194,7 @@ def areaOpSetDefaultValues(self, obj, job):
obj.StepOver = 50
obj.ZigZagAngle = 45.0
obj.ExcludeRaisedAreas = False
obj.ClearEdges = False

# need to overwrite the default depth calculations for facing
if job and len(job.Model.Group) > 0:
Expand Down Expand Up @@ -209,6 +223,7 @@ def isPocket(self, b, f, w):

def getAllIncludedFaces(self, base, env, faceZ):
included = []

eXMin = env.BoundBox.XMin
eXMax = env.BoundBox.XMax
eYMin = env.BoundBox.YMin
Expand Down Expand Up @@ -239,6 +254,7 @@ def isOverlap(fMn, fMx, eMn, eMx):
fYMax = face.BoundBox.YMax
# fZMin = face.BoundBox.ZMin
fZMax = face.BoundBox.ZMax

if fZMax > eZMin:
if isOverlap(fXMin, fXMax, eXMin, eXMax) is True:
if isOverlap(fYMin, fYMax, eYMin, eYMax) is True:
Expand All @@ -252,6 +268,8 @@ def SetupProperties():
setup = PathPocketBase.SetupProperties()
setup.append("BoundaryShape")
setup.append("ExcludeRaisedAreas")
setup.append("ClearEdges")

return setup


Expand All @@ -260,4 +278,5 @@ def Create(name, obj=None):
if obj is None:
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
obj.Proxy = ObjectFace(obj, name)

return obj

0 comments on commit 3ce47af

Please sign in to comment.