From 16d90cfbb9ddc2402ce2764f01052dd83d066073 Mon Sep 17 00:00:00 2001 From: Samuel Abels Date: Mon, 30 Jun 2025 21:48:21 +0200 Subject: [PATCH] CAM: Fix: shape parameters coming from the attributes section in the fctb file were not normalized --- src/Mod/CAM/Path/Tool/toolbit/models/base.py | 6 +++++- src/Mod/CAM/Path/Tool/toolbit/serializers/fctb.py | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Mod/CAM/Path/Tool/toolbit/models/base.py b/src/Mod/CAM/Path/Tool/toolbit/models/base.py index 7f0139db57..3f3c7155a4 100644 --- a/src/Mod/CAM/Path/Tool/toolbit/models/base.py +++ b/src/Mod/CAM/Path/Tool/toolbit/models/base.py @@ -154,8 +154,12 @@ class ToolBit(Asset, ABC): for param_name, param_value in params.items(): tool_bit_shape.set_parameter(param_name, param_value) - # Update attributes; these are stored in the document model object. + # Update attributes; the separation between parameters and attributes + # is currently not well defined, so for now we add them to the + # ToolBitShape and the DocumentObject. + # Discussion: https://github.com/FreeCAD/FreeCAD/issues/21722 for attr_name, attr_value in attr.items(): + tool_bit_shape.set_parameter(attr_name, attr_value) if hasattr(toolbit.obj, attr_name): PathUtil.setProperty(toolbit.obj, attr_name, attr_value) else: diff --git a/src/Mod/CAM/Path/Tool/toolbit/serializers/fctb.py b/src/Mod/CAM/Path/Tool/toolbit/serializers/fctb.py index 90cf28aa0c..0722d770a2 100644 --- a/src/Mod/CAM/Path/Tool/toolbit/serializers/fctb.py +++ b/src/Mod/CAM/Path/Tool/toolbit/serializers/fctb.py @@ -47,7 +47,7 @@ class FCTBSerializer(AssetSerializer): @classmethod def extract_dependencies(cls, data: bytes) -> List[AssetUri]: """Extracts URIs of dependencies from serialized data.""" - Path.Log.info(f"FCTBSerializer.extract_dependencies: raw data = {data!r}") + Path.Log.debug(f"FCTBSerializer.extract_dependencies: raw data = {data!r}") data_dict = json.loads(data.decode("utf-8")) shape = data_dict["shape"] return [ToolBitShape.resolve_name(shape)] @@ -102,7 +102,8 @@ class FCTBSerializer(AssetSerializer): # Find the correct ToolBit subclass for the shape Path.Log.debug( - f"FCTBSerializer.deserialize: shape = {shape!r}, id = {id!r}, params = {shape.get_parameters()}" + f"FCTBSerializer.deserialize: shape = {shape!r}, id = {id!r}," + f" params = {shape.get_parameters()}, attrs = {attrs!r}" ) return ToolBit.from_shape(shape, attrs, id)