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

Command Button Control

3 REPLIES 3
Reply
Message 1 of 4
ebunn3
193 Views, 3 Replies

Command Button Control

Hi,

 

Is there a way to put a command button on an Add-in form that will run some code every time it is clicked?  I see a way to add select buttons but nothing else that I am aware of.

 

I want to do the following steps while the form is open:

 

  • User clicks the select faces button and selects all of the faces they want to perform the operation on.
  • User clicks a command button to perform the operation.
  • The form remains open so they may repeat this process as many times as they want.
  • User hits the OK button to close the form.

 

Any help would be greatly appreciated.  

 

Eric

 

Example Form that I want to add a command button to.

ebunn3_0-1629213858114.png

 

3 REPLIES 3
Message 2 of 4
BrianEkins
in reply to: ebunn3

It's not obvious, but you can add a button to a command dialog adding a BoolValueCommandInput. Depending on the settings it will display as a check box or a button.

 

However, even though you can have a button, you probably can't get the behavior you want.  Whatever actions the command performs are not permanently applied to the model until the OK button is clicked and the command is executed.  Any previews before that are transient and are aborted whenever any command inputs are edited or the command is canceled.  It should be possible to make it appear like the behavior you described where you would save all of the inputs currently defined when the user clicks the button.  For any previews, you would use these to rebuild any previous operations and also show the state of the current operation.  Finally, when the user clicks OK, you would create all of the defined operations. If the user cancels the command, you'll lose everything.

 

You can see a list of all the support command inputs in this topic.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 4
ebunn3
in reply to: ebunn3

Brian,

 

Are there any examples available that would illustrate what you are talking about?

 

Eric

Message 4 of 4
BrianEkins
in reply to: ebunn3

There should be a sample that demonstrates using previews but unfortunately, none of the existing samples do.  I have used the functionality in some of my personal add-ins so I know it works.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com

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