From 43ebc1e6a31ad64754e68b26f7ea9e15b4e7051c Mon Sep 17 00:00:00 2001 From: jffmichi <> Date: Fri, 6 Oct 2023 04:16:19 +0200 Subject: [PATCH] Path: use helper functions from Utils.py instead of directly accessing obj.Base in dressups --- src/Mod/Path/Path/Dressup/DogboneII.py | 5 ++--- src/Mod/Path/Path/Dressup/Gui/LeadInOut.py | 4 ++-- src/Mod/Path/Path/Dressup/Gui/RampEntry.py | 6 +++--- src/Mod/Path/Path/Dressup/Tags.py | 9 +++------ src/Mod/Path/PathTests/TestPathDressupDogboneII.py | 6 ++++-- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/Mod/Path/Path/Dressup/DogboneII.py b/src/Mod/Path/Path/Dressup/DogboneII.py index fd6568f930..df6f4957eb 100644 --- a/src/Mod/Path/Path/Dressup/DogboneII.py +++ b/src/Mod/Path/Path/Dressup/DogboneII.py @@ -25,6 +25,7 @@ import FreeCAD import Path import Path.Base.Generator.dogboneII as dogboneII import Path.Base.Language as PathLanguage +import Path.Dressup.Utils as PathDressup import PathScripts.PathUtils as PathUtils import math @@ -271,9 +272,7 @@ class Proxy(object): return None def toolRadius(self, obj): - if not hasattr(obj.Base, "ToolController"): - return self.toolRadius(obj.Base) - return obj.Base.ToolController.Tool.Diameter.Value / 2 + return PathDressup.toolController(obj.Base).Tool.Diameter.Value / 2 def createBone(self, obj, move0, move1): kink = dogboneII.Kink(move0, move1) diff --git a/src/Mod/Path/Path/Dressup/Gui/LeadInOut.py b/src/Mod/Path/Path/Dressup/Gui/LeadInOut.py index 6cc7eda235..dbd2ac8620 100644 --- a/src/Mod/Path/Path/Dressup/Gui/LeadInOut.py +++ b/src/Mod/Path/Path/Dressup/Gui/LeadInOut.py @@ -142,8 +142,8 @@ class ObjectDressup: return None def setup(self, obj): - obj.Length = obj.Base.ToolController.Tool.Diameter * 0.75 - obj.LengthOut = obj.Base.ToolController.Tool.Diameter * 0.75 + obj.Length = PathDressup.toolController(obj.Base).Tool.Diameter * 0.75 + obj.LengthOut = PathDressup.toolController(obj.Base).Tool.Diameter * 0.75 obj.LeadIn = True obj.LeadOut = True obj.KeepToolDown = False diff --git a/src/Mod/Path/Path/Dressup/Gui/RampEntry.py b/src/Mod/Path/Path/Dressup/Gui/RampEntry.py index 79b98c6363..ec79e763ce 100644 --- a/src/Mod/Path/Path/Dressup/Gui/RampEntry.py +++ b/src/Mod/Path/Path/Dressup/Gui/RampEntry.py @@ -192,8 +192,8 @@ class ObjectDressup: def setup(self, obj): obj.Angle = 60 obj.Method = 2 - if PathDressup.baseOp(obj).StartDepth is not None: - obj.DressupStartDepth = PathDressup.baseOp(obj).StartDepth + if PathDressup.baseOp(obj.Base).StartDepth is not None: + obj.DressupStartDepth = PathDressup.baseOp(obj.Base).StartDepth def execute(self, obj): if not obj.Base: @@ -203,7 +203,7 @@ class ObjectDressup: if not obj.Base.Path: return - if hasattr(obj.Base, 'Active') and not obj.Base.Active: + if not PathDressup.baseOp(obj.Base).Active: path = Path.Path("(inactive operation)") obj.Path = path return diff --git a/src/Mod/Path/Path/Dressup/Tags.py b/src/Mod/Path/Path/Dressup/Tags.py index 15e492fb2a..0bcb01639f 100644 --- a/src/Mod/Path/Path/Dressup/Tags.py +++ b/src/Mod/Path/Path/Dressup/Tags.py @@ -868,12 +868,9 @@ class PathData: return (currentLength, lastTagLength) def defaultTagHeight(self): - if ( - hasattr(self.obj, "Base") - and hasattr(self.obj.Base, "StartDepth") - and hasattr(self.obj.Base, "FinalDepth") - ): - pathHeight = (self.obj.Base.StartDepth - self.obj.Base.FinalDepth).Value + op = PathDressup.baseOp(self.obj.Base) + if hasattr(op, "StartDepth") and hasattr(op, "FinalDepth"): + pathHeight = (op.StartDepth - op.FinalDepth).Value else: pathHeight = self.maxZ - self.minZ height = HoldingTagPreferences.defaultHeight(pathHeight / 2) diff --git a/src/Mod/Path/PathTests/TestPathDressupDogboneII.py b/src/Mod/Path/PathTests/TestPathDressupDogboneII.py index 63b725cc7b..28a2478786 100644 --- a/src/Mod/Path/PathTests/TestPathDressupDogboneII.py +++ b/src/Mod/Path/PathTests/TestPathDressupDogboneII.py @@ -47,6 +47,8 @@ class MockTC(object): class MockOp(object): def __init__(self, path, dia=2): + self.Name = "OP" + self.Label = "OP" self.Path = Path.Path(path) self.ToolController = MockTC(dia) @@ -85,7 +87,7 @@ class MockFeaturePython(object): def CreateDressup(path): op = MockOp(path) - obj = MockFeaturePython("DogboneII") + obj = MockFeaturePython("DressupDogbone") db = Path.Dressup.DogboneII.Proxy(obj, op) obj.Proxy = db return obj @@ -626,7 +628,7 @@ class TestDressupDogboneII(PathTestUtils.PathTestBase): obj = self.test90() - obj2 = MockFeaturePython("DogboneII_") + obj2 = MockFeaturePython("DressupDogbone001") db2 = Path.Dressup.DogboneII.Proxy(obj2, obj) obj2.Proxy = db2 obj2.Incision = Path.Dressup.DogboneII.Incision.Fixed