Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Tool params not saving

1 REPLY 1
Reply
Message 1 of 2
kealan4LBW
77 Views, 1 Reply

Tool params not saving

Hi, 

I'm trying to change parameter values with the API, tool_comment and tool_productId. 

The function below reports blank / Null expressions when it first runs, and then shows the same parameters as having changed later on in the function. 
However, if I go and look up the tool library, the parameters have not updated over there. 
If I call the function twice, it reports the parameters being Null/Blank again the second time it runs - which is not as expected - so it's like the tool parameters aren't getting saved or something so they look OK from within the scope of the function but they're not getting pushed back out to fusion properly.

Any ideas? 

 

for url in local_lib_url_list:
        local_lib_names.append(toolLibraries.displayName(url))

        toolLibrary = toolLibraries.toolLibraryAtURL(url)

        for tool in toolLibrary:

            futil.log(f"BEFORE Tool_comment value is: {tool.parameters.itemByName('tool_comment').expression}")
            futil.log(f"BEFORE Tool_productId value is: {tool.parameters.itemByName('tool_productId').expression}")

            
            item1 = tool.parameters.itemByName('tool_comment')
            item1.expression = "Scripted"

            item2 = tool.parameters.itemByName('tool_productId')
            item2.expression = "Scripted"

            futil.log(f"AFTER Tool_comment value is: {tool.parameters.itemByName('tool_comment').expression}")
            futil.log(f"AFTER Tool_productId value is: {tool.parameters.itemByName('tool_productId').expression}")

            #debug line  to check if manually edited library changes appear in the script read values.
            futil.log(f" Tool_vendor value is: {tool.parameters.itemByName('tool_vendor').expression}")

        
            futil.log("______________________END OF TOOL______________________________________________")

 

 

1 REPLY 1
Message 2 of 2
kandennti
in reply to: kealan4LBW

Hi @kealan4LBW -San.

 

I have not tried it, but it looks like you probably need to do the ToolLibraries.updateToolLibrary method.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-A6D44A3E-7E21-4AEA-B561-BFB9F45F9F28 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report