What is event API to close and then re-create an Add-In under Python control?

What is event API to close and then re-create an Add-In under Python control?

tim.collins29V9X
Enthusiast Enthusiast
343 Views
2 Replies
Message 1 of 3

What is event API to close and then re-create an Add-In under Python control?

tim.collins29V9X
Enthusiast
Enthusiast

I think I need to fire a couple events. I am using "custom events" already so I don't think this should be too hard:

  1. Simulate the user clicking on the "Close" button from inside my Python add-in.
  2. Simulate the user opening it again from the Fusion 360 menu.

The UI is is built in the CommandCreated event handler based somewhat on the contents of a disk file. If the user wants to read in a different file then the UI must be re-created. The proposed pseudo code is:

 

  1. Ask if any changed data should be saved into a file.
  2. Use the file open dialog to locate the file to open
  3. Set the file name where it will be caught in the Command Created event.
  4. Close the add-in dialog
  5. Select the add-in from the menu (say, "Utilities" --> "My Thing")
  6. Read the file name from step 3 instead of using the defaults

I have a feeling this was already answered but I didn't happen to spot it.

0 Likes
344 Views
2 Replies
Replies (2)
Message 2 of 3

Jorge_Jaramillo
Collaborator
Collaborator

Hi @tim.collins29V9X ,

 

I'd suggest to make the changes to the command, instead of trying to re-run the add-in.

 

You can remove all the command inputs from the command, and then add then according with the definitions you have in your file. 

You can define a procedure that read the information you need to build the command, and call it from the create_handler at the beginning of the add-in execution, and any time you need it to rebuild the command.

 

Hope this help.

 

Regards,
Jorge

0 Likes
Message 3 of 3

tim.collins29V9X
Enthusiast
Enthusiast

Thanks, Jorge. Yes, I will try your suggestion. My code has clean interfaces to create and tear down the controls already. 

It sounds like there is no such feature to "push the buttons" programmatically. If this feature did exist it would have the advantage that it would be executing code that is already tested and reliable. Too often when I just "try" something that wasn't anticipated by the original developers I end up wasting time. Sometimes a lot of time. 

 

 

0 Likes