Instigate Cancel Button Click using code (Python)

Instigate Cancel Button Click using code (Python)

ebunn3
Advocate Advocate
986 Views
2 Replies
Message 1 of 3

Instigate Cancel Button Click using code (Python)

ebunn3
Advocate
Advocate

Hi,

 

Is there a way to close an open userform with code (like hitting the Cancel button)?  Currently I have a message box popup instructing the user to close and reopen the form after a certain action is taken.  I would like to automatically close the form when this happens instead of prompting them to hit cancel.

 

Thanks in advance,

 

Eric

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

BrianEkins
Mentor
Mentor
Accepted solution

There is no way to cancel a message box.

 

I thought there was a way to cancel a command dialog but just looked and see it was never implemented. There should be a doCancel method on the command that would be the equivalent of clicking the Cancel button on the command dialog. A workaround will be to execute another command, which will terminate the currently running command. The default command in Fusion, when no other command is running is the "Select" command. You can execute that to kill the current command and put Fusion in its default state.

 

selCommand = ui.commandDefinitions.itemByName('SelectCommand')
selCommand.execute()
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 3

ebunn3
Advocate
Advocate

Thank you Brian.  I'll try it out.

 

Eric

0 Likes