Merge pull request #26647 from Connor9220/FixToolbitLabelAndControllerNaming

CAM: Fix duplicate label issues with toolbits
This commit is contained in:
sliptonic
2026-01-05 11:15:02 -06:00
committed by GitHub
2 changed files with 20 additions and 3 deletions

View File

@@ -1149,7 +1149,9 @@ class TaskPanel:
toolbit = selector.get_selected_tool()
toolbit.attach_to_doc(FreeCAD.ActiveDocument)
toolNum = self.obj.Proxy.nextToolNumber()
tc = PathToolControllerGui.Create(name=toolbit.label, tool=toolbit.obj, toolNumber=toolNum)
tc = PathToolControllerGui.Create(
name=f"TC: {toolbit.label}", tool=toolbit.obj, toolNumber=toolNum
)
self.obj.Proxy.addToolController(tc)
FreeCAD.ActiveDocument.recompute()

View File

@@ -718,8 +718,23 @@ class ToolBitShape(Asset):
# Recompute the document to apply property changes
tmp_doc.recompute()
# Copy the body to the given document without immediate compute.
return doc.copyObject(shape, True)
# Temporarily disable duplicate labels to let FreeCAD automatically
# make labels unique during the copy operation
param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Document")
original_setting = param.GetBool("DuplicateLabels", False)
try:
# Disable duplicate labels temporarily
param.SetBool("DuplicateLabels", False)
# Copy the body - FreeCAD will now automatically make labels unique
copied_shape = doc.copyObject(shape, True)
return copied_shape
finally:
# Restore the original setting
param.SetBool("DuplicateLabels", original_setting)
"""
Retrieves the thumbnail data for the tool bit shape in PNG format.