How to assign an existing tool to an operation without duplicating the tool?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Fusionists,
I am writing a CAM script that duplicates an operation and modifies the parameters of the new operation based on the values of the previous one. It works alright, but there is one thing that drives me nuts:
The new operation gets its tool reassigned to the next one in the current Document Tool Library. But every time this occurs, a new instance of the tool is created in the current Document Tool Library instead of just reusing the one that already exists.
Here's the code extract in question:
currentOp = currentSetup.operations.item(i)
toolNb = currentOp.tool.parameters.itemByName('tool_number').value.value
currentOp.duplicate()
i = i+1
newOp = currentSetup.operations.item(i)
newOp.tool = cam.documentToolLibrary.item(toolNb+1)
So let's say that operation#1 was using T2, when operation#2 (the duplicate) gets assigned T3, my Document Tool Library now contains two identical T3 tools.
I banged my head against this thing for a few hours yesterday and finally gave up and asked our favorite chatbot for some help and I was told that this is the way it is... when assigning a tool from the current document with the API, a duplicate will always be created no matter what. I couldn't find any mention of this in the documentation...
Is there a workaround for this?
Much thanks!