Renamed PathProfile to PathProfileFaces for consistency; moved common depth calculation for ops with BaseGeometry into PathAreaOp.
This commit is contained in:
committed by
Yorik van Havre
parent
4c5ba38404
commit
1e76c99250
@@ -56,8 +56,8 @@ SET(PathScripts_SRCS
|
||||
PathScripts/PathPreferences.py
|
||||
PathScripts/PathPreferencesPathDressup.py
|
||||
PathScripts/PathPreferencesPathJob.py
|
||||
PathScripts/PathProfile.py
|
||||
PathScripts/PathProfileGui.py
|
||||
PathScripts/PathProfileFaces.py
|
||||
PathScripts/PathProfileFacesGui.py
|
||||
PathScripts/PathProfileEdges.py
|
||||
PathScripts/PathSanity.py
|
||||
PathScripts/PathSelection.py
|
||||
|
||||
@@ -67,7 +67,7 @@ class PathWorkbench (Workbench):
|
||||
from PathScripts import PathPlane
|
||||
from PathScripts import PathPocketGui
|
||||
from PathScripts import PathPost
|
||||
from PathScripts import PathProfileGui
|
||||
from PathScripts import PathProfileFacesGui
|
||||
from PathScripts import PathProfileEdges
|
||||
from PathScripts import PathSanity
|
||||
from PathScripts import PathSimpleCopy
|
||||
|
||||
@@ -110,11 +110,56 @@ class ObjectOp(object):
|
||||
pass
|
||||
def opSetDefaultValues(self, obj):
|
||||
pass
|
||||
def opShapeForDepths(self, obj):
|
||||
job = PathUtils.findParentJob(obj)
|
||||
if job and job.Base:
|
||||
PathLog.debug("job=%s base=%s shape=%s" % (job, job.Base, job.Base.Shape))
|
||||
return job.Base.Shape
|
||||
PathLog.warning(translate("PathAreaOp", "No job object found (%s), or job has no Base." % job))
|
||||
return None
|
||||
|
||||
|
||||
def onChanged(self, obj, prop):
|
||||
#PathLog.track(obj.Label, prop)
|
||||
if prop in ['AreaParams', 'PathParams', 'removalshape']:
|
||||
obj.setEditorMode(prop, 2)
|
||||
|
||||
if FeatureBaseGeometry & self.opFeatures(obj):
|
||||
if prop == 'Base' and len(obj.Base) == 1:
|
||||
try:
|
||||
(base, sub) = obj.Base[0]
|
||||
bb = base.Shape.BoundBox # parent boundbox
|
||||
subobj = base.Shape.getElement(sub[0])
|
||||
fbb = subobj.BoundBox # feature boundbox
|
||||
obj.StartDepth = bb.ZMax
|
||||
obj.ClearanceHeight = bb.ZMax + 5.0
|
||||
obj.SafeHeight = bb.ZMax + 3.0
|
||||
|
||||
if fbb.ZMax == fbb.ZMin and fbb.ZMax == bb.ZMax: # top face
|
||||
obj.FinalDepth = bb.ZMin
|
||||
elif fbb.ZMax > fbb.ZMin and fbb.ZMax == bb.ZMax: # vertical face, full cut
|
||||
obj.FinalDepth = fbb.ZMin
|
||||
elif fbb.ZMax > fbb.ZMin and fbb.ZMin > bb.ZMin: # internal vertical wall
|
||||
obj.FinalDepth = fbb.ZMin
|
||||
elif fbb.ZMax == fbb.ZMin and fbb.ZMax > bb.ZMin: # face/shelf
|
||||
obj.FinalDepth = fbb.ZMin
|
||||
else: # catch all
|
||||
obj.FinalDepth = bb.ZMin
|
||||
|
||||
if hasattr(obj, 'Side'):
|
||||
if bb.XLength == fbb.XLength and bb.YLength == fbb.YLength:
|
||||
obj.Side = "Outside"
|
||||
else:
|
||||
obj.Side = "Inside"
|
||||
|
||||
except Exception as e:
|
||||
PathLog.error(translate("PatArea", "Error in calculating depths: %s" % e))
|
||||
obj.StartDepth = 5.0
|
||||
obj.ClearanceHeight = 10.0
|
||||
obj.SafeHeight = 8.0
|
||||
if hasattr(obj, 'Side'):
|
||||
obj.Side = "Outside"
|
||||
|
||||
self.opOnChanged(obj, prop)
|
||||
|
||||
def setDefaultValues(self, obj):
|
||||
|
||||
@@ -86,14 +86,6 @@ class ObjectContour(PathAreaOp.ObjectOp):
|
||||
else:
|
||||
obj.setEditorMode('MiterLimit', 2)
|
||||
|
||||
def opShapeForDepths(self, obj):
|
||||
job = PathUtils.findParentJob(obj)
|
||||
if job and job.Base:
|
||||
PathLog.debug("job=%s base=%s shape=%s" % (job, job.Base, job.Base.Shape))
|
||||
return job.Base.Shape
|
||||
PathLog.warning("No job object found (%s), or job has no Base." % job)
|
||||
return None
|
||||
|
||||
def opSetDefaultValues(self, obj):
|
||||
obj.Direction = "CW"
|
||||
obj.UseComp = True
|
||||
|
||||
@@ -67,14 +67,6 @@ class ObjectPocket(PathAreaOp.ObjectOp):
|
||||
def opUseProjection(self, obj):
|
||||
return False
|
||||
|
||||
def opShapeForDepths(self, obj):
|
||||
job = PathUtils.findParentJob(obj)
|
||||
if job and job.Base:
|
||||
PathLog.debug("job=%s base=%s shape=%s" % (job, job.Base, job.Base.Shape))
|
||||
return job.Base.Shape
|
||||
PathLog.warning("No job object found (%s), or job has no Base." % job)
|
||||
return None
|
||||
|
||||
def opAreaParams(self, obj, isHole):
|
||||
params = {}
|
||||
params['Fill'] = 0
|
||||
@@ -136,34 +128,6 @@ class ObjectPocket(PathAreaOp.ObjectOp):
|
||||
obj.StepOver = 100
|
||||
obj.ZigZagAngle = 45
|
||||
|
||||
def opOnChanged(self, obj, prop):
|
||||
#PathLog.track(obj.Label, prop)
|
||||
if prop == 'Base' and len(obj.Base) == 1:
|
||||
try:
|
||||
(base, sub) = obj.Base[0]
|
||||
bb = base.Shape.BoundBox # parent boundbox
|
||||
subobj = base.Shape.getElement(sub[0])
|
||||
fbb = subobj.BoundBox # feature boundbox
|
||||
obj.StartDepth = bb.ZMax
|
||||
obj.ClearanceHeight = bb.ZMax + 5.0
|
||||
obj.SafeHeight = bb.ZMax + 3.0
|
||||
|
||||
if fbb.ZMax == fbb.ZMin and fbb.ZMax == bb.ZMax: # top face
|
||||
obj.FinalDepth = bb.ZMin
|
||||
elif fbb.ZMax > fbb.ZMin and fbb.ZMax == bb.ZMax: # vertical face, full cut
|
||||
obj.FinalDepth = fbb.ZMin
|
||||
elif fbb.ZMax > fbb.ZMin and fbb.ZMin > bb.ZMin: # internal vertical wall
|
||||
obj.FinalDepth = fbb.ZMin
|
||||
elif fbb.ZMax == fbb.ZMin and fbb.ZMax > bb.ZMin: # face/shelf
|
||||
obj.FinalDepth = fbb.ZMin
|
||||
else: # catch all
|
||||
obj.FinalDepth = bb.ZMin
|
||||
except Exception as e:
|
||||
PathLog.error(translate("PathPocket", "Error in calculating depths: %s" % e))
|
||||
obj.StartDepth = 5.0
|
||||
obj.ClearanceHeight = 10.0
|
||||
obj.SafeHeight = 8.0
|
||||
|
||||
|
||||
def Create(name):
|
||||
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
|
||||
|
||||
@@ -59,13 +59,15 @@ class ObjectProfile(PathAreaOp.ObjectOp):
|
||||
obj.Direction = ['CW', 'CCW'] # this is the direction that the profile runs
|
||||
obj.addProperty("App::PropertyBool", "UseComp", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "make True, if using Cutter Radius Compensation"))
|
||||
obj.addProperty("App::PropertyDistance", "OffsetExtra", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Extra value to stay away from final profile- good for roughing toolpath"))
|
||||
obj.addProperty("App::PropertyBool", "processHoles", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Profile holes as well as the outline"))
|
||||
obj.addProperty("App::PropertyBool", "processPerimeter", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Profile the outline"))
|
||||
obj.addProperty("App::PropertyBool", "processCircles", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Profile round holes"))
|
||||
obj.addProperty("App::PropertyEnumeration", "JoinType", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Controls how tool moves around corners. Default=Round"))
|
||||
obj.JoinType = ['Round', 'Square', 'Miter'] # this is the direction that the Contour runs
|
||||
obj.addProperty("App::PropertyFloat", "MiterLimit", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Maximum distance before a miter join is truncated"))
|
||||
|
||||
# Face specific Properties
|
||||
obj.addProperty("App::PropertyBool", "processHoles", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Profile holes as well as the outline"))
|
||||
obj.addProperty("App::PropertyBool", "processPerimeter", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Profile the outline"))
|
||||
obj.addProperty("App::PropertyBool", "processCircles", "Profile", QtCore.QT_TRANSLATE_NOOP("App::Property", "Profile round holes"))
|
||||
|
||||
obj.Proxy = self
|
||||
|
||||
def opSetDefaultValues(self, obj):
|
||||
@@ -73,11 +75,13 @@ class ObjectProfile(PathAreaOp.ObjectOp):
|
||||
obj.OffsetExtra = 0.0
|
||||
obj.Direction = "CW"
|
||||
obj.UseComp = True
|
||||
obj.processHoles = False
|
||||
obj.processPerimeter = True
|
||||
obj.JoinType = "Round"
|
||||
obj.MiterLimit = 0.1
|
||||
|
||||
obj.processHoles = False
|
||||
obj.processCircles = False
|
||||
obj.processPerimeter = True
|
||||
|
||||
def onOpChanged(self, obj, prop):
|
||||
if prop == "UseComp":
|
||||
if not obj.UseComp:
|
||||
@@ -90,53 +94,12 @@ class ObjectProfile(PathAreaOp.ObjectOp):
|
||||
if obj.JoinType == 'Miter':
|
||||
obj.setEditorMode('MiterLimit', 0)
|
||||
|
||||
if prop == 'Base' and len(obj.Base) == 1:
|
||||
try:
|
||||
(base, sub) = obj.Base[0]
|
||||
bb = base.BoundBox # parent boundbox
|
||||
subobj = base.getElement(sub)
|
||||
fbb = subobj.BoundBox # feature boundbox
|
||||
obj.StartDepth = bb.ZMax
|
||||
obj.ClearanceHeight = bb.ZMax + 5.0
|
||||
obj.SafeHeight = bb.ZMax + 3.0
|
||||
|
||||
if fbb.ZMax == fbb.ZMin and fbb.ZMax == bb.ZMax: # top face
|
||||
obj.FinalDepth = bb.ZMin
|
||||
elif fbb.ZMax > fbb.ZMin and fbb.ZMax == bb.ZMax: # vertical face, full cut
|
||||
obj.FinalDepth = fbb.ZMin
|
||||
elif fbb.ZMax > fbb.ZMin and fbb.ZMin > bb.ZMin: # internal vertical wall
|
||||
obj.FinalDepth = fbb.ZMin
|
||||
elif fbb.ZMax == fbb.ZMin and fbb.ZMax > bb.ZMin: # face/shelf
|
||||
obj.FinalDepth = fbb.ZMin
|
||||
else: # catch all
|
||||
obj.FinalDepth = bb.ZMin
|
||||
|
||||
if bb.XLength == fbb.XLength and bb.YLength == fbb.YLength:
|
||||
obj.Side = "Outside"
|
||||
else:
|
||||
obj.Side = "Inside"
|
||||
|
||||
except Exception as e:
|
||||
PathLog.error(translate("PathPocket", "Error in calculating depths: %s" % e))
|
||||
obj.StartDepth = 5.0
|
||||
obj.ClearanceHeight = 10.0
|
||||
obj.SafeHeight = 8.0
|
||||
obj.Side = "Outside"
|
||||
|
||||
def opFeatures(self, obj):
|
||||
return PathAreaOp.FeatureTool | PathAreaOp.FeatureDepths | PathAreaOp.FeatureHeights | PathAreaOp.FeatureStartPoint | PathAreaOp.FeatureBaseFaces
|
||||
|
||||
def opUseProjection(self, obj):
|
||||
return True
|
||||
|
||||
def opShapeForDepths(self, obj):
|
||||
job = PathUtils.findParentJob(obj)
|
||||
if job and job.Base:
|
||||
PathLog.debug("job=%s base=%s shape=%s" % (job, job.Base, job.Base.Shape))
|
||||
return job.Base.Shape
|
||||
PathLog.warning("No job object found (%s), or job has no Base." % job)
|
||||
return None
|
||||
|
||||
def opAreaParams(self, obj, isHole):
|
||||
params = {}
|
||||
params['Fill'] = 0
|
||||
@@ -27,7 +27,7 @@ import FreeCADGui
|
||||
import Path
|
||||
import PathScripts.PathAreaOpGui as PathAreaOpGui
|
||||
import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathProfile as PathProfile
|
||||
import PathScripts.PathProfileFaces as PathProfileFaces
|
||||
import PathScripts.PathSelection as PathSelection
|
||||
|
||||
from PathScripts import PathUtils
|
||||
@@ -79,7 +79,7 @@ class TaskPanelOpPage(PathAreaOpGui.TaskPanelPage):
|
||||
return signals
|
||||
|
||||
PathAreaOpGui.SetupOperation('Profile',
|
||||
PathProfile.Create,
|
||||
PathProfileFaces.Create,
|
||||
TaskPanelOpPage,
|
||||
'Path-Profile',
|
||||
QtCore.QT_TRANSLATE_NOOP("PathProfile", "Face Profile"),
|
||||
Reference in New Issue
Block a user