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: 

internal command button events

2 REPLIES 2
Reply
Message 1 of 3
manni9999
490 Views, 2 Replies

internal command button events

Hi,
in an addin i have some userdefined buttons created.
-Create Buttondefinition with .add
-Create event sink
-Write a _onexcute sub
This works fine.

Now I Want to do same same with an internal command.

'buttons
Private oMyButton As Inventor.ButtonDefinition

oMyButton = oControlDefs.item("AppFilePrintCmd")

'connect the button event sink
AddHandler oMyButton.OnExecute, AddressOf
Me.MyButton_OnExecute

Private Sub MyButton_OnExecute(ByVal Context As NameValueMap)

'MsgBox("Hello")

end sub

The buttondfinition is ok.
I can access the properties of the builtin Command for example "DisplayName"

The event sink seems to be ok too.
No errors occurs.

But it seems, that the procedur Mybutton_onexecute
is not executed when the button gets a click.

So my question is, what is going wrong?
I suggest, that inventor does not execute this because an internal command cannot be overrided by user code.
But what can I do to get the information that the user clicks the button?
I want to do something before the command is executed
and then excute the command.
I my case I want to write a time stamp on a sheet before
the AppFilePrintCmd Command is executed.

Manfred
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: manni9999

As you've found, the OnExecute event does not fire for internal commands.
You can use the following events on UserInputEvents object to monitor
commands being activated and terminated: OnActivateCommand &
OnTerminateCommand.

Sanjay-
Message 3 of 3
Boorda
in reply to: manni9999

I know this post is pretty old but I wanted to add a more in depth example of what Sanjay what talking about.

  

         ABOVE your  Public Sub Activate(ByVal addInSiteObject As ....  sub in your add-in, add the following code:

    

          Private WithEvents m_UserInputEvents As Inventor.UserInputEvents

 

        IN your  Public Sub Activate(ByVal addInSiteObject As .... sub add the following code:

   

          m_UserInputEvents = oApp.CommandManager.UserInputEvents

        

    Then you will need to add some new subs to catch these events...

 

     #Region "Inventor Events"

 

               Public Sub InvOnActivateCommand(ByVal CommandName As String, _

               ByVal Context As Inventor.NameValueMap) Handles m_UserInputEvents.OnActivateCommand

                          'Your Code here....

               End Sub

 

               Public Sub InvOnTerminateCommand(ByVal CommandName As String, _

               ByVal Context As Inventor.NameValueMap) Handles m_UserInputEvents.OnTerminateCommand

                         'Your Code here....

               End Sub

 

      #End Region


Automation is key!

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

Post to forums  

Autodesk Design & Make Report