Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi! Im trying to make a script or an Api to change the tool_descriptions to a unique number (kind of ID) through a script.
I'm able to read everything from the tools I want to change but it seems like it's not possible to change the value. I can change the variables but it is never displayed inside the Library.
Can anyone help me?
Here is the code I use:
#Author-
#Description-
import adsk.core, adsk.fusion, adsk.cam, traceback
import json
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
# Get a reference to the CAMManager object.
camMgr = adsk.cam.CAMManager.get()
# Get the ToolLibraries object.
toolLibs = camMgr.libraryManager.toolLibraries
# Get the URL for the local libraries.
localLibLocationURL = toolLibs.urlByLocation(adsk.cam.LibraryLocations.LocalLibraryLocation)
# Get the URL of the folder, which will be for the "CustomTools" folder.
f360FolderURLs = toolLibs.childFolderURLs(localLibLocationURL)
BuildToolsFolderURL = f360FolderURLs[0]
# ui.messageBox("DIE URL lautet {}" .format(BuildToolsFolderURL))
# Get the "Millingtools" library.
f360LibraryURLs = toolLibs.childAssetURLs(BuildToolsFolderURL)
toolLib = None
for libURL in f360LibraryURLs:
if 'Millingtools' in libURL.leafName:
toolLib = toolLibs.toolLibraryAtURL(libURL)
# Find a specific tool.
for tool in toolLib:
tooldesc = tool.parameters.itemByName('tool_description')
tooldesc.expression = "123456"
ui.messageBox("New toolname is {}".format(tooldesc.expression))
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.