Path: use helper functions from Utils.py instead of directly accessing obj.Base in dressups

This commit is contained in:
jffmichi
2023-10-06 04:16:19 +02:00
parent aec49039ba
commit 43ebc1e6a3
5 changed files with 14 additions and 16 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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