Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

What command is active?

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
tobias_wiesendanger
257 Views, 6 Replies

What command is active?

I know that there is something like this: invApp.CommandManager.ActiveCommand which tells me what command is active. The problem im facing is, on fast pc's if a command is clicked this will be the button you just clicked and on slower pc's it looks like it is the command that was active before clicking the button. (Not 100% sure if thats the case, but it looks like it)

 

I need to now what command was active before clicking the button. Depending on what it was the method should immediately return. Any ideas how to achieve that?

6 REPLIES 6
Message 2 of 7

Hi @tobias_wiesendanger.  That is a tough one.  Are you just talking about any given button in Inventor's user interface, or are you talking about a button for a custom Inventor add-in that you have control over?  If you have access to that specific ControlDefinition, then your add-in will receive the notification of the Click event.  But if it is not add-in related, then the main thing that comes to mind is maybe attempting to monitor the UserInputEvents.OnActivateCommand Event, and the UserInputEvents.OnTerminateCommand Event.  Those Events will of course be triggered a ton, so the code used for monitoring them would need to be pretty efficient to avoid slowing Inventor down.  On the down side of using those events is that although they both have a 'Context' (NameValueMap), neither of them currently offer any information within that Context, so they are fairly basic.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 7

It is addin related. So the button that is clicked is from my addin but I dont think that changes anything. 

 

The idea with the command events is a good one. I think I will try that one. The code would be very efficient because I could just set the last command that was used.

Message 4 of 7

Or check the undo list.

Message 5 of 7

Not sure how the undo list should help?

 

Events seam tricky as well. Depending on the system they are firing before or after the method.

Message 6 of 7

It collect commands since last save.

Maybe able to find command before button click.

It's transaction in API:

https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-EB4D4D34-C84F-494A-8665-D87EF536B38F

Message 7 of 7

Yeah but only if you started a transaction before, which I cannot do. I do a  invApp.CommandManager.StopActiveCommand(); before now. This should work for my case.

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

Post to forums  

Autodesk Design & Make Report