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: 

ExecutePreview Event Without Full Rebuild

Message 1 of 2
513 Views, 1 Reply

ExecutePreview Event Without Full Rebuild

I'm creating a new component with a couple sketches, extrudes, and revolves. Currently my Python Add-In is rebuilding all of the geometry after every user input change. It's even doing it while a multi-digit number is being entered into an input field. This causes a lot of lag. Is there a way to keep the previous preview and just edit what changed? I added an if statement to the ExecutePreview function, but the preview disappears on the second event call when I don't build the geometry.


Could I save the component to a global variable, then re-insert it somehow? It doesn't make sense to recreate all the sketch lines and constraints when the user only changed the extrude length.

Message 2 of 2
in reply to: commonmandan

The way commands work is that whatever you construct in the executePreview is all built within a single transaction.  When the next executePreview is fired that transaction is aborted (the equivalent of an undo) so you can construct the next preview.  There isn't a way to preserve any created entities from one executePreview to another.  One option is to create a simplified preview in the executePreview event and then create the final, more expensive, result in the execute event.  The isValidResult property of the CommandEventArgs object passed into the executePreview event indicates if the geometry you build in the executePreview is to be used as the final result when the command is executed.  If this is set to False, the result created in the executePreview is aborted and the execute event is called.  If it is set to True then the execute event is skipped and the last result of the executePreview is used as the final result.

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

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

Post to forums  

Technology Administrators

Autodesk Design & Make Report