Add-ins that trigger on file open

Add-ins that trigger on file open

Anonymous
Not applicable
458 Views
1 Reply
Message 1 of 2

Add-ins that trigger on file open

Anonymous
Not applicable

I have written a simple script that performs a simple scaling operation on a model. I would like the script to trigger every time on a file if I open the file (and Fusion 360). Currently if I just copy the code over to a Add-in, I am not able to get the current model; since the add-in will attempt to finish running (on Fusion startup) before Fusion 360 attempts to open the file. I was wondering if it is possible to delay this add-in from triggering until the file is fully loaded or if there is a way to have opening a file trigger this operation.

0 Likes
459 Views
1 Reply
Reply (1)
Message 2 of 2

ekinsb
Alumni
Alumni

The Application object supports the documentOpened event that you can use for this.  It seems like you would also want to mark the documents that you want your add-in to do this work in to because it doesn't seem like you would want this to happen when you open any document.  The marking could be done in many ways.  The best is if you can somehow recognize the valid documents based on their contents in some way.  For example, if there is a certain series of features or if a feature or sketch has a specific name.  Another option would be to edit the properties of the root component and add something into the description that your add-in can look for.

 

One other approach for marking the file is to create an attribute on the root document that your add-in would look for.  All of these are valid and the best choice will depend on your workflow and models.

 

The basic approach is:

  • Your add-in is loaded by Fusion and connects to the documentOpened event inside the Run function.
  • When the documentOpened event is fired by Fusion your add-in will examine the document to see if it's a valid document for the operation.
  • If the document is "marked" then the add-in will perform the scaling operation. 

 

 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes