Opening the Scripts/AddIns window through Python API Call

Opening the Scripts/AddIns window through Python API Call

anson_tsang9VU5G
Explorer Explorer
676 Views
2 Replies
Message 1 of 3

Opening the Scripts/AddIns window through Python API Call

anson_tsang9VU5G
Explorer
Explorer

Hello, I am currently working on an Add-in that creates a Fusion 360 script in Python base on some user commands. However, I am stuck on figuring out how I can run the script in the background automatically. Is there a way to run another script so that the user does not have to open the window and click run manually?

 

If that isn't possible, is there a method to directly open the scripts/Add-In window through some sort of API call, for example:

adsk.core.OpenWindow.("Scripts and Add-Ins")

 

Thanks for reading this message. Looking forward to contribute to the Autodesk 360 community.

 

 

0 Likes
Accepted solutions (1)
677 Views
2 Replies
Replies (2)
Message 2 of 3

Jorge_Jaramillo
Collaborator
Collaborator

Hi,

 

You can open the scripts and add-ins window with the following code:

 

    cmd = app.userInterface.commandDefinitions.itemById('ScriptsManagerCommand')

    if cmd:
        cmd.execute()

 

Then the user need to select the script to be run and click "Run" to execute it.

 

If you want to avoid the user interaction to select and run the script, you might need to run the code of the script directly on the add-in in the point you were expecting to open the scripts and add-in window.

 

I don't know a way to run the script automatically, or at least didn't find it in the API documentation.

 

Best regards,

Jorge Jaramillo

 

Message 3 of 3

kandennti
Mentor
Mentor
Accepted solution

Hi @anson_tsang9VU5G -San.

 

I have run a test that calls another script from a Fusion360 script.

 

The attached script has an entry point of "call_script_test.py".
I imported and called "target_script.py" in the same folder as a dynamic module.
If "Hello Target Script" is output to the text command window, it is a success.


However, there was a limitation when calling the script from an add-in.
If you run a script that uses a dialog, the add-in also exits when the script exits.

0 Likes