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: 

Watch for specific event

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
gert-leonvanlier
638 Views, 5 Replies

Watch for specific event

Probably it is pretty simple what I am looking for, but I can not find the answer.

 

I want to create a (custom) event in my add in using C#. With the even watcher I found the command I want to watch for is UserInputEvents.OnActivateCommand with command name "VaultCheckinTop". How do I create an events that watches this event?

Labels (2)
5 REPLIES 5
Message 2 of 6

Hello

 

Just listen to the OnActivateCommand event and every time it fires, check if CommandName is "VaultCheckinTop". There's no specific event "VaultCheckinTop" you can listen to.


R. Krieg
RKW Solutions GmbH
www.rkw-solutions.com
Message 3 of 6

I created this method:

private void ui_OnActivateCommand(String CommandName, NameValueMap Context)
{
	switch (CommandName)
	{
		case "VaultCheckin":
			MessageBox.Show("VaultCheckin");
			break;
		case "VaultCheckinTop":
			MessageBox.Show("VaultCheckinTop");
			break;
	}
}

 

I am now looking on how to trigger this method. ApplicationEvents are triggered by for example this:

Globals.invApp.ApplicationEvents.OnDocumentChange += onChange;

 

I can't find anything for UserInputEvents or OnActivateCommand.

 

Message 4 of 6

Found it!

 

The following is placed in the Activate method of the add in:

Globals.invApp.CommandManager.UserInputEvents.OnActivateCommand += UserInputEvents_OnActivateCommand;

 

And this is in my case the method for the OnActivateCommand:

private void UserInputEvents_OnActivateCommand(string CommandName, NameValueMap Context)
{
	switch (CommandName)
	{
		case "VaultCheckin":
			MessageBox.Show("VaultCheckin");
			break;
		case "VaultCheckinTop":
			MessageBox.Show("VaultCheckinTop");
			break;
	}
}

 

Message 5 of 6

I just found out that this events works as some kind of before: when you click the button, the event is fired. At that point I can run some code and after that the check in window is shown. Although you can't choose for before or after, is there a way to have my code to run after the check in window is shown?

Message 6 of 6

Hello

 

Thats right and that's why it is called "OnActivate".

You can check if the OnTerminateCommand (this should fire if the command is finished or aborted) is useable. Maybe it would be a better way to use the (Webservice)API of Vault server direct.

 


R. Krieg
RKW Solutions GmbH
www.rkw-solutions.com

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

Post to forums  

Autodesk Design & Make Report