Handle event for button added inside Inventor User Interface

Handle event for button added inside Inventor User Interface

Anonymous
Not applicable
1,227 Views
7 Replies
Message 1 of 8

Handle event for button added inside Inventor User Interface

Anonymous
Not applicable

Hi,

I am trying to develop external application.First I run the Inventor.Open new part in Inventor.After that create new panel and button inside the panel successfully in Inventor UI.But I am not able to catch the event when press on the button.

Any suggestion is most welcome

 

0 Likes
Accepted solutions (1)
1,228 Views
7 Replies
Replies (7)
Message 2 of 8

barbara.han
Alumni
Alumni
Have you tried listening to UserInputEvents.OnActivateCommand event? It should return you the command name which you defined, so you can have a chance to perform your logic. If above way doesn't work, the another solution is to call ControlDefinition.Delete method on the button that you created through UI, and create a new ControlDefinition through programming, then add it to the panel. This way, OnExecute event should fire when the button is pressed from UI.
Barbara Han
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 3 of 8

Anonymous
Not applicable
Hi , Thanks for reply. I would like send demo project to you. I have applied the suggestion mentioned by you, still it is not working. I have written the one main function in DLL and reffering this DLL in EXE Application. Please check the attached code.
0 Likes
Message 4 of 8

barbara.han
Alumni
Alumni

I have not seen sample attached. Where is it?

Barbara Han
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 5 of 8

Anonymous
Not applicable

Hi ,

Please see the attached code.

0 Likes
Message 6 of 8

ekinsb
Alumni
Alumni
Accepted solution

I think you're just listening for the wrong event.  The event you want to handle is the OnExecute event of ButtonDefinition object.  This is the appropriate one to listen to for your own buttons.  The OnActivateCommand event is for listening for the execution of standard Inventor commands, not buttons that have been added through the API.  I've attached a simplified program that's a bit easier to follow since it gets rid of the redirection in your original code.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 7 of 8

barbara.han
Alumni
Alumni

Brian's comment is right.

 

Viewing your first post, I thought the button is created by you from Inventor UI, instead of the program, so I suggested you to listen to OnActivateCommand event. But you should directly listen to OnExecute event if this button is created by your program. They are two different situation.

 

I don't know if we can still add OnExecute event handler to the button that is created manually from UI. I have not tested this. If you have such need, you can check this way. Using OnExecute should be more efficient than using OnActivateCommand.

 

Barbara Han
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 8 of 8

Anonymous
Not applicable

Thanks it is working.

0 Likes