From 24c32c9841f6b1114dde37a8bc7a21cbe64a839f Mon Sep 17 00:00:00 2001 From: jffmichi <> Date: Sun, 4 May 2025 20:18:34 +0200 Subject: [PATCH] CAM: bring Array dressup in line with existing dressups --- src/Mod/CAM/CMakeLists.txt | 1 - src/Mod/CAM/Path/Dressup/Array.py | 17 +++--- src/Mod/CAM/Path/Dressup/Base.py | 91 ------------------------------- 3 files changed, 10 insertions(+), 99 deletions(-) delete mode 100644 src/Mod/CAM/Path/Dressup/Base.py diff --git a/src/Mod/CAM/CMakeLists.txt b/src/Mod/CAM/CMakeLists.txt index 0a09f4ae58..0221cca79a 100644 --- a/src/Mod/CAM/CMakeLists.txt +++ b/src/Mod/CAM/CMakeLists.txt @@ -60,7 +60,6 @@ SET(PathPythonDressup_SRCS Path/Dressup/__init__.py Path/Dressup/Utils.py Path/Dressup/Array.py - Path/Dressup/Base.py Path/Dressup/Boundary.py Path/Dressup/DogboneII.py Path/Dressup/Tags.py diff --git a/src/Mod/CAM/Path/Dressup/Array.py b/src/Mod/CAM/Path/Dressup/Array.py index 398ada044e..41a5d6678a 100644 --- a/src/Mod/CAM/Path/Dressup/Array.py +++ b/src/Mod/CAM/Path/Dressup/Array.py @@ -24,7 +24,7 @@ import FreeCAD import Path import PathScripts.PathUtils as PathUtils -from Path.Dressup.Base import DressupBase +import Path.Dressup.Utils as PathDressup import random from PySide.QtCore import QT_TRANSLATE_NOOP @@ -33,10 +33,14 @@ __doc__ = """CAM Array dressup""" translate = FreeCAD.Qt.translate -class DressupArray(DressupBase): +class DressupArray: def __init__(self, obj, base, job): - super().__init__(obj, base) - + obj.addProperty( + "App::PropertyLink", + "Base", + "Path", + QT_TRANSLATE_NOOP("App::Property", "The base toolpath to modify"), + ) obj.addProperty( "App::PropertyEnumeration", "Type", @@ -119,7 +123,6 @@ class DressupArray(DressupBase): self.obj = obj obj.Base = base - obj.Active = True # assigning array tells the type of possible enum choices obj.Type = ["Linear1D", "Linear2D", "Polar"] # assign value @@ -178,14 +181,14 @@ class DressupArray(DressupBase): obj.Base = None return True - def dressupExecute(self, obj): + def execute(self, obj): if not obj.Base or not obj.Base.isDerivedFrom("Path::Feature") or not obj.Base.Path: Path.Log.error(translate("PathArray", "Base is empty or an invalid object.")) return None # Do not generate paths and clear current Path data if operation not active - if not obj.Active: + if not PathDressup.baseOp(obj.Base).Active: if obj.Path: obj.Path = Path.Path() return diff --git a/src/Mod/CAM/Path/Dressup/Base.py b/src/Mod/CAM/Path/Dressup/Base.py deleted file mode 100644 index a53f14554d..0000000000 --- a/src/Mod/CAM/Path/Dressup/Base.py +++ /dev/null @@ -1,91 +0,0 @@ -from PySide.QtCore import QT_TRANSLATE_NOOP - -from Path.Op.Base import ObjectOp - - -class DressupBase: - """ - Base class for all dressups to provide common interface with the rest of CAM - One major example is making sure all dressups export base operation settings - like coolant, tool controller, etc. - """ - - def setup_coolant_property(self, obj): - if not hasattr(obj, "CoolantMode"): - obj.addProperty( - "App::PropertyEnumeration", - "CoolantMode", - "CoolantMode", - QT_TRANSLATE_NOOP("App::Property", "Default coolant mode."), - ) - - for n in ObjectOp.opPropertyEnumerations(): - if n[0] == "CoolantMode": - setattr(obj, n[0], n[1]) - - def setup_tool_controller_property(self, obj): - if not hasattr(obj, "ToolController"): - obj.addProperty( - "App::PropertyLink", - "ToolController", - "Path", - QT_TRANSLATE_NOOP( - "App::Property", - "The tool controller that will be used to calculate the path", - ), - ) - - def __init__(self, obj, base): - - obj.addProperty( - "App::PropertyLink", - "Base", - "Base", - QT_TRANSLATE_NOOP("App::Property", "The base path to modify"), - ) - - obj.addProperty( - "App::PropertyBool", - "Active", - "Path", - QT_TRANSLATE_NOOP( - "App::Property", "Make False, to prevent operation from generating code" - ), - ) - - self.setup_coolant_property(obj) - self.setup_tool_controller_property(obj) - - def onDocumentRestored(self, obj): - """ - Called then document is being restored. Often used for object migrations, - adding missing properties, etc. - Do not overwrite - child classes should use dressupOnDocumentRestored(). - """ - self.setup_coolant_property(obj) - self.setup_tool_controller_property(obj) - - def dressupOnDocumentRestored(self, obj): - """Overwrite this method for custom handling.""" - pass - - def execute(self, obj): - """ - Export common properties from base object and - run dressupExecute() - """ - - if hasattr(obj, "Base") and hasattr(obj.Base, "CoolantMode"): - obj.CoolantMode = obj.Base.CoolantMode - - if hasattr(obj, "Base") and hasattr(obj.Base, "ToolController"): - obj.ToolController = obj.Base.ToolController - - return self.dressupExecute(obj) - - def dressupExecute(self, obj): - """ - Called whenever receiver should be recalculated. - Should be overwritten by subclasses. - """ - pass