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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Run on startup

Message 1 of 3
792 Views, 2 Replies

Run on startup

Hello there.


Me and my buddy working on some Addin -


First version almost done, but we have problem with feature Run on startup.


Run Startup.PNG


Our AddIn just do not wonna start by in self with Fusion, and every time user have to go Scripts and Addin to run it manually.


Where here could be a problem? Is in Fusion any special code lines for Run on startup feature?

Message 2 of 3
in reply to: copypastestd

I'm not sure why your program is showing up on the Add-Ins tab but I took a look at your code and it's a script, not an add-in.  There are two things that make it a script.  The first is the contents of the .manifest file.  You can see in there that the type is defined as "script".  Looking at your code itself, you also have script specific code.  In the run function you're creating the command definition and then executing it, and setting the autoTerminate so the script doesn't stop running.  That's all correct when implementing a command within a script.


For an add-in you can still re-use almost all of your code.  The main difference will be in the run function where you'll need to add a button to somewhere into Fusion's toolbar.  You don't need to set the autoTerminate because an add-in doesn't automatically terminate.  When the user clicks the button you created that will result in the command created event being fired to your add-in and your command will run like it does now.  An add-in also has a stop function that is called when your add-in is unloaded.


I would recommend using the Script and Add-Ins command to create a new add-in and then copy and paste most of your code from your script into the add-in.  Most of your existing code in the run function can still be used but you'll need to add the code to create the button.  You'll also need to add code to the stop function to clean up the ui when your add-in is unloaded.  This topic from the online help should help.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 3
in reply to: ekinsb

In previous message I forgot to say that actual code was in branch AddIn (I have already merged that branch into master).


Frankly, I have found my mistake, I tried to call that lines:


 design = adsk.fusion.Design.cast(product)
 rootComp = design.rootComponent

out of methods, as global paremeters.

When it was Script, everything worked fine, but when it became AddIn - we got Run On Startup error.


Tnx for your time and help.

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