Black
This commit is contained in:
@@ -42,44 +42,108 @@ def translate(context, text, disambig=None):
|
||||
|
||||
|
||||
class ObjectPocket(PathAreaOp.ObjectOp):
|
||||
'''Base class for proxy objects of all pocket operations.'''
|
||||
"""Base class for proxy objects of all pocket operations."""
|
||||
|
||||
def areaOpFeatures(self, obj):
|
||||
'''areaOpFeatures(obj) ... Pockets have a FinishDepth and work on Faces'''
|
||||
return PathOp.FeatureBaseFaces | PathOp.FeatureFinishDepth | self.pocketOpFeatures(obj)
|
||||
"""areaOpFeatures(obj) ... Pockets have a FinishDepth and work on Faces"""
|
||||
return (
|
||||
PathOp.FeatureBaseFaces
|
||||
| PathOp.FeatureFinishDepth
|
||||
| self.pocketOpFeatures(obj)
|
||||
)
|
||||
|
||||
def pocketOpFeatures(self, obj):
|
||||
# pylint: disable=unused-argument
|
||||
return 0
|
||||
|
||||
def initPocketOp(self, obj):
|
||||
'''initPocketOp(obj) ... overwrite to initialize subclass.
|
||||
Can safely be overwritten by subclass.'''
|
||||
pass # pylint: disable=unnecessary-pass
|
||||
"""initPocketOp(obj) ... overwrite to initialize subclass.
|
||||
Can safely be overwritten by subclass."""
|
||||
pass # pylint: disable=unnecessary-pass
|
||||
|
||||
def pocketInvertExtraOffset(self):
|
||||
'''pocketInvertExtraOffset() ... return True if ExtraOffset's direction is inward.
|
||||
Can safely be overwritten by subclass.'''
|
||||
"""pocketInvertExtraOffset() ... return True if ExtraOffset's direction is inward.
|
||||
Can safely be overwritten by subclass."""
|
||||
return False
|
||||
|
||||
def initAreaOp(self, obj):
|
||||
'''initAreaOp(obj) ... create pocket specific properties.
|
||||
Do not overwrite, implement initPocketOp(obj) instead.'''
|
||||
"""initAreaOp(obj) ... create pocket specific properties.
|
||||
Do not overwrite, implement initPocketOp(obj) instead."""
|
||||
PathLog.track()
|
||||
|
||||
# Pocket Properties
|
||||
obj.addProperty("App::PropertyEnumeration", "CutMode", "Pocket", QtCore.QT_TRANSLATE_NOOP("App::Property", "The direction that the toolpath should go around the part ClockWise (CW) or CounterClockWise (CCW)"))
|
||||
obj.addProperty("App::PropertyDistance", "ExtraOffset", "Pocket", QtCore.QT_TRANSLATE_NOOP("App::Property", "Extra offset to apply to the operation. Direction is operation dependent."))
|
||||
obj.addProperty("App::PropertyEnumeration", "StartAt", "Pocket", QtCore.QT_TRANSLATE_NOOP("App::Property", "Start pocketing at center or boundary"))
|
||||
obj.addProperty("App::PropertyPercent", "StepOver", "Pocket", QtCore.QT_TRANSLATE_NOOP("App::Property", "Percent of cutter diameter to step over on each pass"))
|
||||
obj.addProperty("App::PropertyFloat", "ZigZagAngle", "Pocket", QtCore.QT_TRANSLATE_NOOP("App::Property", "Angle of the zigzag pattern"))
|
||||
obj.addProperty("App::PropertyEnumeration", "OffsetPattern", "Face", QtCore.QT_TRANSLATE_NOOP("App::Property", "Clearing pattern to use"))
|
||||
obj.addProperty("App::PropertyBool", "MinTravel", "Pocket", QtCore.QT_TRANSLATE_NOOP("App::Property", "Use 3D Sorting of Path"))
|
||||
obj.addProperty("App::PropertyBool", "KeepToolDown", "Pocket", QtCore.QT_TRANSLATE_NOOP("App::Property", "Attempts to avoid unnecessary retractions."))
|
||||
obj.addProperty(
|
||||
"App::PropertyEnumeration",
|
||||
"CutMode",
|
||||
"Pocket",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"The direction that the toolpath should go around the part ClockWise (CW) or CounterClockWise (CCW)",
|
||||
),
|
||||
)
|
||||
obj.addProperty(
|
||||
"App::PropertyDistance",
|
||||
"ExtraOffset",
|
||||
"Pocket",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Extra offset to apply to the operation. Direction is operation dependent.",
|
||||
),
|
||||
)
|
||||
obj.addProperty(
|
||||
"App::PropertyEnumeration",
|
||||
"StartAt",
|
||||
"Pocket",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
"App::Property", "Start pocketing at center or boundary"
|
||||
),
|
||||
)
|
||||
obj.addProperty(
|
||||
"App::PropertyPercent",
|
||||
"StepOver",
|
||||
"Pocket",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
"App::Property", "Percent of cutter diameter to step over on each pass"
|
||||
),
|
||||
)
|
||||
obj.addProperty(
|
||||
"App::PropertyFloat",
|
||||
"ZigZagAngle",
|
||||
"Pocket",
|
||||
QtCore.QT_TRANSLATE_NOOP("App::Property", "Angle of the zigzag pattern"),
|
||||
)
|
||||
obj.addProperty(
|
||||
"App::PropertyEnumeration",
|
||||
"OffsetPattern",
|
||||
"Face",
|
||||
QtCore.QT_TRANSLATE_NOOP("App::Property", "Clearing pattern to use"),
|
||||
)
|
||||
obj.addProperty(
|
||||
"App::PropertyBool",
|
||||
"MinTravel",
|
||||
"Pocket",
|
||||
QtCore.QT_TRANSLATE_NOOP("App::Property", "Use 3D Sorting of Path"),
|
||||
)
|
||||
obj.addProperty(
|
||||
"App::PropertyBool",
|
||||
"KeepToolDown",
|
||||
"Pocket",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
"App::Property", "Attempts to avoid unnecessary retractions."
|
||||
),
|
||||
)
|
||||
|
||||
obj.CutMode = ['Climb', 'Conventional']
|
||||
obj.StartAt = ['Center', 'Edge']
|
||||
obj.OffsetPattern = ['ZigZag', 'Offset', 'Spiral', 'ZigZagOffset', 'Line', 'Grid', 'Triangle']
|
||||
obj.CutMode = ["Climb", "Conventional"]
|
||||
obj.StartAt = ["Center", "Edge"]
|
||||
obj.OffsetPattern = [
|
||||
"ZigZag",
|
||||
"Offset",
|
||||
"Spiral",
|
||||
"ZigZagOffset",
|
||||
"Line",
|
||||
"Grid",
|
||||
"Triangle",
|
||||
]
|
||||
|
||||
self.initPocketOp(obj)
|
||||
|
||||
@@ -88,40 +152,48 @@ class ObjectPocket(PathAreaOp.ObjectOp):
|
||||
return not obj.KeepToolDown
|
||||
|
||||
def areaOpUseProjection(self, obj):
|
||||
'''areaOpUseProjection(obj) ... return False'''
|
||||
"""areaOpUseProjection(obj) ... return False"""
|
||||
return False
|
||||
|
||||
def areaOpAreaParams(self, obj, isHole):
|
||||
'''areaOpAreaParams(obj, isHole) ... return dictionary with pocket's area parameters'''
|
||||
"""areaOpAreaParams(obj, isHole) ... return dictionary with pocket's area parameters"""
|
||||
params = {}
|
||||
params['Fill'] = 0
|
||||
params['Coplanar'] = 0
|
||||
params['PocketMode'] = 1
|
||||
params['SectionCount'] = -1
|
||||
params['Angle'] = obj.ZigZagAngle
|
||||
params['FromCenter'] = (obj.StartAt == "Center")
|
||||
params['PocketStepover'] = (self.radius * 2) * (float(obj.StepOver)/100)
|
||||
params["Fill"] = 0
|
||||
params["Coplanar"] = 0
|
||||
params["PocketMode"] = 1
|
||||
params["SectionCount"] = -1
|
||||
params["Angle"] = obj.ZigZagAngle
|
||||
params["FromCenter"] = obj.StartAt == "Center"
|
||||
params["PocketStepover"] = (self.radius * 2) * (float(obj.StepOver) / 100)
|
||||
extraOffset = obj.ExtraOffset.Value
|
||||
if self.pocketInvertExtraOffset():
|
||||
extraOffset = 0 - extraOffset
|
||||
params['PocketExtraOffset'] = extraOffset
|
||||
params['ToolRadius'] = self.radius
|
||||
params["PocketExtraOffset"] = extraOffset
|
||||
params["ToolRadius"] = self.radius
|
||||
|
||||
Pattern = ['ZigZag', 'Offset', 'Spiral', 'ZigZagOffset', 'Line', 'Grid', 'Triangle']
|
||||
params['PocketMode'] = Pattern.index(obj.OffsetPattern) + 1
|
||||
Pattern = [
|
||||
"ZigZag",
|
||||
"Offset",
|
||||
"Spiral",
|
||||
"ZigZagOffset",
|
||||
"Line",
|
||||
"Grid",
|
||||
"Triangle",
|
||||
]
|
||||
params["PocketMode"] = Pattern.index(obj.OffsetPattern) + 1
|
||||
|
||||
if obj.SplitArcs:
|
||||
params['Explode'] = True
|
||||
params['FitArcs'] = False
|
||||
params["Explode"] = True
|
||||
params["FitArcs"] = False
|
||||
|
||||
return params
|
||||
|
||||
def areaOpPathParams(self, obj, isHole):
|
||||
'''areaOpAreaParams(obj, isHole) ... return dictionary with pocket's path parameters'''
|
||||
"""areaOpAreaParams(obj, isHole) ... return dictionary with pocket's path parameters"""
|
||||
params = {}
|
||||
|
||||
CutMode = ['Conventional', 'Climb']
|
||||
params['orientation'] = CutMode.index(obj.CutMode)
|
||||
CutMode = ["Conventional", "Climb"]
|
||||
params["orientation"] = CutMode.index(obj.CutMode)
|
||||
|
||||
# if MinTravel is turned on, set path sorting to 3DSort
|
||||
# 3DSort shouldn't be used without a valid start point. Can cause
|
||||
@@ -133,19 +205,19 @@ class ObjectPocket(PathAreaOp.ObjectOp):
|
||||
# any problem
|
||||
#
|
||||
if obj.MinTravel and obj.UseStartPoint and obj.StartPoint is not None:
|
||||
params['sort_mode'] = 3
|
||||
params['threshold'] = self.radius * 2
|
||||
params["sort_mode"] = 3
|
||||
params["threshold"] = self.radius * 2
|
||||
return params
|
||||
|
||||
|
||||
def SetupProperties():
|
||||
setup = PathAreaOp.SetupProperties()
|
||||
setup.append('CutMode')
|
||||
setup.append('ExtraOffset')
|
||||
setup.append('StepOver')
|
||||
setup.append('ZigZagAngle')
|
||||
setup.append('OffsetPattern')
|
||||
setup.append('StartAt')
|
||||
setup.append('MinTravel')
|
||||
setup.append('KeepToolDown')
|
||||
setup.append("CutMode")
|
||||
setup.append("ExtraOffset")
|
||||
setup.append("StepOver")
|
||||
setup.append("ZigZagAngle")
|
||||
setup.append("OffsetPattern")
|
||||
setup.append("StartAt")
|
||||
setup.append("MinTravel")
|
||||
setup.append("KeepToolDown")
|
||||
return setup
|
||||
|
||||
Reference in New Issue
Block a user