From c3f03d3696cdb81bb5f761a504a7445014edb17c Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Sun, 21 Jan 2018 20:06:11 -0800 Subject: [PATCH] Removed ToolController from all dressups and replaced with recursive search for the base op's ToolController. --- src/Mod/Path/PathScripts/PathDressup.py | 10 ++++++++ .../Path/PathScripts/PathDressupDogbone.py | 5 ++-- .../PathScripts/PathDressupHoldingTags.py | 12 +++++---- .../Path/PathScripts/PathDressupLeadInOut.py | 13 ++++------ .../Path/PathScripts/PathDressupRampEntry.py | 25 ++++++------------- src/Mod/Path/PathScripts/PathDressupTag.py | 3 ++- src/Mod/Path/utils/path-lint.sh | 3 ++- 7 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathDressup.py b/src/Mod/Path/PathScripts/PathDressup.py index 6d187b1caf..abf82e3ff4 100644 --- a/src/Mod/Path/PathScripts/PathDressup.py +++ b/src/Mod/Path/PathScripts/PathDressup.py @@ -42,3 +42,13 @@ def hasEntryMethod(path): return hasEntryMethod(path.Base) return False +def baseOp(path): + '''baseOp(path) ... return the base operation underlying the given path''' + if 'Dressup' in path.Name: + return baseOp(path.Base) + return path + +def toolController(path): + '''toolController(path) ... return the tool controller from the base op.''' + return baseOp(path).ToolController + diff --git a/src/Mod/Path/PathScripts/PathDressupDogbone.py b/src/Mod/Path/PathScripts/PathDressupDogbone.py index 811896e284..57f8516720 100644 --- a/src/Mod/Path/PathScripts/PathDressupDogbone.py +++ b/src/Mod/Path/PathScripts/PathDressupDogbone.py @@ -28,6 +28,7 @@ import FreeCADGui import math import Part import Path +import PathScripts.PathDressup as PathDressup import PathScripts.PathLog as PathLog import PathScripts.PathUtil as PathUtil import PathScripts.PathUtils as PathUtils @@ -362,7 +363,6 @@ class ObjectDressup: def __init__(self, obj, base): # Tool Properties - obj.addProperty("App::PropertyLink", "ToolController", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The tool controller that will be used to calculate the path")) obj.addProperty("App::PropertyLink", "Base", "Base", QtCore.QT_TRANSLATE_NOOP("Path_DressupDogbone", "The base path to modify")) obj.addProperty("App::PropertyEnumeration", "Side", "Dressup", QtCore.QT_TRANSLATE_NOOP("Path_DressupDogbone", "The side of path to insert bones")) obj.Side = [Side.Left, Side.Right] @@ -803,7 +803,7 @@ class ObjectDressup: obj.Side = side self.toolRadius = 5 - tc = obj.ToolController + tc = PathDressup.toolController(obj.Base) if tc is None or tc.ToolNumber == 0: self.toolRadius = 5 else: @@ -1014,7 +1014,6 @@ def Create(base, name='DogboneDressup'): ViewProviderDressup(obj.ViewObject) obj.Base.ViewObject.Visibility = False - obj.ToolController = base.ToolController dbo.setup(obj, True) return obj diff --git a/src/Mod/Path/PathScripts/PathDressupHoldingTags.py b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py index b3c271e67d..30c849e347 100644 --- a/src/Mod/Path/PathScripts/PathDressupHoldingTags.py +++ b/src/Mod/Path/PathScripts/PathDressupHoldingTags.py @@ -24,6 +24,7 @@ import FreeCAD import Part import Path +import PathScripts.PathDressup as PathDressup import PathScripts.PathLog as PathLog import PathScripts.PathUtil as PathUtil import PathScripts.PathUtils as PathUtils @@ -788,10 +789,11 @@ class ObjectTagDressup: lastCmd = Path.Command('G0', {'X': 0.0, 'Y': 0.0, 'Z': 0.0}) outCommands = [] - horizFeed = obj.Base.ToolController.HorizFeed.Value - vertFeed = obj.Base.ToolController.VertFeed.Value - horizRapid = obj.Base.ToolController.HorizRapid.Value - vertRapid = obj.Base.ToolController.VertRapid.Value + tc = PathDressup.toolController(obj.Base) + horizFeed = tc.HorizFeed.Value + vertFeed = tc.VertFeed.Value + horizRapid = tc.HorizRapid.Value + vertRapid = tc.VertRapid.Value for cmd in commands: params = cmd.Parameters @@ -936,7 +938,7 @@ class ObjectTagDressup: PathLog.error(translate("Path_DressupTag", "Cannot insert holding tags for this path - please select a Profile path\n")) return None - self.toolRadius = obj.Base.ToolController.Tool.Diameter / 2 + self.toolRadius = PathDressup.toolController(obj.Base).Tool.Diameter / 2 self.pathData = pathData if generate: obj.Height = self.pathData.defaultTagHeight() diff --git a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py index 11e0675782..832dbb5095 100644 --- a/src/Mod/Path/PathScripts/PathDressupLeadInOut.py +++ b/src/Mod/Path/PathScripts/PathDressupLeadInOut.py @@ -55,7 +55,6 @@ class ObjectDressup: def __init__(self, obj): self.obj = obj - obj.addProperty("App::PropertyLink", "ToolController", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The tool controller that will be used to calculate the path")) obj.addProperty("App::PropertyLink", "Base", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The base path to modify")) obj.addProperty("App::PropertyBool", "LeadIn", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "Calculate roll-on to path")) obj.addProperty("App::PropertyBool", "LeadOut", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "Calculate roll-off from path")) @@ -85,9 +84,6 @@ class ObjectDressup: obj.StyleOn = 'Arc' obj.StyleOff = 'Arc' obj.RadiusCenter = 'Radius' - if obj.Base: - if hasattr(obj.Base,"ToolController"): - obj.ToolController = obj.Base.ToolController def execute(self, obj): if not obj.Base: @@ -127,9 +123,10 @@ class ObjectDressup: global currLocation results = [] # zdepth = currLocation["Z"] - horizFeed = obj.Base.ToolController.HorizFeed.Value - vertFeed = obj.Base.ToolController.VertFeed.Value - toolnummer = obj.Base.ToolController.ToolNumber + tc = PathDressup.toolController(obj.Base) + horizFeed = tc.HorizFeed.Value + vertFeed = tc.VertFeed.Value + toolnummer = tc.ToolNumber # set the correct twist command if self.getDirectionOfPath(obj) == 'left': arcdir = "G3" @@ -189,7 +186,7 @@ class ObjectDressup: '''returns the Gcode of LeadOut.''' global currLocation results = [] - horizFeed = obj.Base.ToolController.HorizFeed.Value + horizFeed = PathDressup.toolController(obj.Base).HorizFeed.Value R = obj.Length.Value # Radius of roll or length # set the correct twist command if self.getDirectionOfPath(obj) == 'right': diff --git a/src/Mod/Path/PathScripts/PathDressupRampEntry.py b/src/Mod/Path/PathScripts/PathDressupRampEntry.py index caf6d11ac4..8571956d3d 100644 --- a/src/Mod/Path/PathScripts/PathDressupRampEntry.py +++ b/src/Mod/Path/PathScripts/PathDressupRampEntry.py @@ -46,7 +46,6 @@ class ObjectDressup: def __init__(self, obj): self.obj = obj - obj.addProperty("App::PropertyLink", "ToolController", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The tool controller that will be used to calculate the path")) obj.addProperty("App::PropertyLink", "Base", "Path", QtCore.QT_TRANSLATE_NOOP("Path_DressupRampEntry", "The base path to modify")) obj.addProperty("App::PropertyAngle", "Angle", "Path", QtCore.QT_TRANSLATE_NOOP("Path_DressupRampEntry", "Angle of ramp.")) obj.addProperty("App::PropertyEnumeration", "Method", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "Ramping Method")) @@ -76,15 +75,6 @@ class ObjectDressup: def setup(self, obj): obj.Angle = 60 obj.Method = 2 - toolLoad = obj.ToolController - if toolLoad is None or toolLoad.ToolNumber == 0: - PathLog.error(translate("No Tool Controller is selected. We need a tool to build a Path\n")) - return - else: - tool = toolLoad.Proxy.getTool(toolLoad) - if not tool: - PathLog.error(translate("No Tool found. We need a tool to build a Path.\n")) - return def execute(self, obj): @@ -520,16 +510,18 @@ class ObjectDressup: outCommands = [] - horizFeed = obj.ToolController.HorizFeed.Value - vertFeed = obj.ToolController.VertFeed.Value + tc = PathDressup.toolController(obj.Base) + + horizFeed = tc.HorizFeed.Value + vertFeed = tc.VertFeed.Value if obj.RampFeedRate == "Horizontal Feed Rate": - rampFeed = obj.ToolController.HorizFeed.Value + rampFeed = tc.HorizFeed.Value elif obj.RampFeedRate == "Vertical Feed Rate": - rampFeed = obj.ToolController.VertFeed.Value + rampFeed = tc.VertFeed.Value else: rampFeed = obj.CustomFeedRate.Value - horizRapid = obj.ToolController.HorizRapid.Value - vertRapid = obj.ToolController.VertRapid.Value + horizRapid = tc.HorizRapid.Value + vertRapid = tc.VertRapid.Value for cmd in commands: params = cmd.Parameters @@ -644,7 +636,6 @@ class CommandPathDressupRampEntry: FreeCADGui.doCommand('PathScripts.PathDressupRampEntry.ViewProviderDressup(obj.ViewObject)') FreeCADGui.doCommand('PathScripts.PathUtils.addToJob(obj)') FreeCADGui.doCommand('Gui.ActiveDocument.getObject(obj.Base.Name).Visibility = False') - FreeCADGui.doCommand('obj.ToolController = PathScripts.PathUtils.findToolController(obj)') FreeCADGui.doCommand('dbo.setup(obj)') FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() diff --git a/src/Mod/Path/PathScripts/PathDressupTag.py b/src/Mod/Path/PathScripts/PathDressupTag.py index 6b0ca28c09..03c984dddf 100644 --- a/src/Mod/Path/PathScripts/PathDressupTag.py +++ b/src/Mod/Path/PathScripts/PathDressupTag.py @@ -24,6 +24,7 @@ import FreeCAD import DraftGeomUtils import Part +import PathScripts.PathDressup as PathDressup import PathScripts.PathLog as PathLog import PathScripts.PathUtils as PathUtils import math @@ -211,7 +212,7 @@ class ObjectDressup: PathLog.track() def toolRadius(self): - return self.obj.Base.ToolController.Tool.Diameter / 2.0 + return PathDressup.toolController(self.obj.Base).Tool.Diameter / 2.0 def addTagsToDocuemnt(self): for i, solid in enumerate(self.solids): diff --git a/src/Mod/Path/utils/path-lint.sh b/src/Mod/Path/utils/path-lint.sh index 317058d63a..4ced99d487 100755 --- a/src/Mod/Path/utils/path-lint.sh +++ b/src/Mod/Path/utils/path-lint.sh @@ -58,4 +58,5 @@ if [ -z "$(which pylint)" ]; then exit 1 fi -pylint ${ARGS} PathScripts/ PathTests/ +#pylint ${ARGS} PathScripts/ PathTests/ +pylint ${ARGS} PathScripts/