<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Change tools through API in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/change-tools-through-api/m-p/12729539#M1549</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/506514"&gt;@jeff.pek&lt;/a&gt;&amp;nbsp;-San.&lt;BR /&gt;&lt;BR /&gt;I had overlooked it. Thanks for letting me know.&lt;/P&gt;</description>
    <pubDate>Wed, 24 Apr 2024 06:39:10 GMT</pubDate>
    <dc:creator>kandennti</dc:creator>
    <dc:date>2024-04-24T06:39:10Z</dc:date>
    <item>
      <title>Change tools through API</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/change-tools-through-api/m-p/12724274#M1546</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Can anyone help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I use:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;#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()))&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 22 Apr 2024 06:54:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/change-tools-through-api/m-p/12724274#M1546</guid>
      <dc:creator>j_zander</dc:creator>
      <dc:date>2024-04-22T06:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Change tools through API</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/change-tools-through-api/m-p/12725280#M1547</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7953068"&gt;@j_zander&lt;/a&gt;&amp;nbsp;-San.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think it is not possible to change the tool settings in ToolLibrary.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;The only tool settings that can be changed are those that are called into the document.&lt;BR /&gt;I made a simple sample.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;# Fusion360API Python script

import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        cam: adsk.cam.CAM = app.activeProduct
        toolLib: adsk.cam.DocumentToolLibrary = cam.documentToolLibrary

        for tool in toolLib:
            tooldesc = tool.parameters.itemByName('tool_description')
            tooldesc.expression = "123456"

            toolLib.update(tool, True)

        ui.messageBox("Done")

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The DocumentToolLibrary object has an update method, and executing this will confirm the change.&lt;BR /&gt;However, the ToolLibrary object does not have an update method.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-C0A61669-1C70-4A68-8CAA-158108844FC7" target="_blank" rel="noopener"&gt;https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-C0A61669-1C70-4A68-8CAA-158108844FC7&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-1C9482B1-CEAA-4D48-83ED-DDA9637372D2" target="_blank" rel="noopener"&gt;https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-1C9482B1-CEAA-4D48-83ED-DDA9637372D2&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a side note, I pointed out earlier that the description of the update method in Help was incorrect, but it has not been fixed yet.&lt;BR /&gt;Please take a look at this reply and the next one and you will see what I mean.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/fusion-api-and-scripts/manufacturing-cam-api-feedback/m-p/11876509#M18776" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/fusion-api-and-scripts/manufacturing-cam-api-feedback/m-p/11876509#M18776&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 14:47:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/change-tools-through-api/m-p/12725280#M1547</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2024-04-22T14:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: Change tools through API</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/change-tools-through-api/m-p/12727722#M1548</link>
      <description>&lt;P&gt;The ToolLibraries object has an updateToolLibrary method, which should be able to be used to save changes to non-document-based tools.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeff&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2024 13:38:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/change-tools-through-api/m-p/12727722#M1548</guid>
      <dc:creator>jeff.pek</dc:creator>
      <dc:date>2024-04-23T13:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Change tools through API</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/change-tools-through-api/m-p/12729539#M1549</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/506514"&gt;@jeff.pek&lt;/a&gt;&amp;nbsp;-San.&lt;BR /&gt;&lt;BR /&gt;I had overlooked it. Thanks for letting me know.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 06:39:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/change-tools-through-api/m-p/12729539#M1549</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2024-04-24T06:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: Change tools through API</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/change-tools-through-api/m-p/12729636#M1550</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3787950"&gt;@kandennti&lt;/a&gt;&amp;nbsp; this works for me very well, thanks a lot. I think it is the easiest way to setup a new tool in the documentlibrary, give it the ID via script and copy it to my allmillingtools lib manually.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/506514"&gt;@jeff.pek&lt;/a&gt;&amp;nbsp; i found that method but I couldn't figure out how to use it. I don't understand which attributes to set. Maybe you can help me with that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jan&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 07:38:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/change-tools-through-api/m-p/12729636#M1550</guid>
      <dc:creator>j_zander</dc:creator>
      <dc:date>2024-04-24T07:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: Change tools through API</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/change-tools-through-api/m-p/12730599#M1551</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7953068"&gt;@j_zander&lt;/a&gt;&amp;nbsp;-San.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first your code worked with the following modification.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;・・・
        # Get the "Millingtools" library.
        f360LibraryURLs = toolLibs.childAssetURLs(BuildToolsFolderURL)
        toolLib = None
        toolLibURL = ""
        for libURL in f360LibraryURLs:
            if 'Millingtools' in libURL.leafName:
                toolLib = toolLibs.toolLibraryAtURL(libURL)
                toolLibURL = 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))

        # update toollib.
        toolLibs.updateToolLibrary(toolLibURL, toolLib)
・・・&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 24 Apr 2024 13:48:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/change-tools-through-api/m-p/12730599#M1551</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2024-04-24T13:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Change tools through API</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/change-tools-through-api/m-p/12730765#M1552</link>
      <description>thank you very much!</description>
      <pubDate>Wed, 24 Apr 2024 14:37:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/change-tools-through-api/m-p/12730765#M1552</guid>
      <dc:creator>j_zander</dc:creator>
      <dc:date>2024-04-24T14:37:10Z</dc:date>
    </item>
  </channel>
</rss>

