Run on startup

Run on startup

copypastestd
Advocate Advocate
1,557 Views
2 Replies
Message 1 of 3

Run on startup

copypastestd
Advocate
Advocate

Hello there.

 

Me and my buddy working on some Addin - https://github.com/PhilippNox/NiceBox-360

 

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?

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

ekinsb
Alumni
Alumni

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.

 

http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-F31C76F0-8C74-4343-904C-68FDA9BB8B4C

 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 3

copypastestd
Advocate
Advocate
Accepted solution

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.