01-12-2017
03:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
01-12-2017
03:11 PM
Hi,
This is how you can run things inside your own command.
Here is a VBA sample.
E.g. have a class named "MyCommand" with this code:
Option Explicit
Dim WithEvents bd As ButtonDefinition
Private Sub bd_OnExecute(ByVal Context As NameValueMap)
Dim ie As InteractionEvents
Set ie = ThisApplication.CommandManager.CreateInteractionEvents
' Set name of ActiveCommand
ie.Name = "MyCommand"
Call ie.Start
' Do something as part of the command
Call MsgBox("ThisApplication.CommandManager.ActiveCommand = " + _
ThisApplication.CommandManager.ActiveCommand)
Call ie.Stop
End Sub
Private Sub Class_Initialize()
Dim cm As CommandManager
Set cm = ThisApplication.CommandManager
Set bd = cm.ControlDefinitions.AddButtonDefinition( _
"MyCommand", "MyCommand", kNonShapeEditCmdType, , "MyCommand", , , , kAlwaysDisplayText)
' Run it Synchronous=True
Call bd.Execute2(True)
' If it was really synchronous then by the time we get
' here we're done and don't need the command anymore
Call bd.Delete
End Sub
Then instantiate it from a module:
Dim mc As MyCommand Sub RunMyCommand() Set mc = New MyCommand End Sub
This way while your command is running, the ActiveCommand will be "MyCommand" and OnActivateCommand/OnTerminateCommand events should fire as well.
PS: I have a couple of largeish assemblies I just could not make Inventor think too much after an Update yet.
I'll try to find a way for that.
Cheers,

Adam Nagy
Autodesk Platform Services