use inventor command in contextual menu

use inventor command in contextual menu

petrxn
Advocate Advocate
1,101 Views
4 Replies
Message 1 of 5

use inventor command in contextual menu

petrxn
Advocate
Advocate

Hello,

is there any possibility to use inventor commands like "AppContextual_ContinueCmd" in addin? I need to add to RadialMarkingMenu commands for continue or cancel during selection. 

private void UIEvents_OnRadialMarkingMenu(Inventor.ObjectsEnumerator toEntities, Inventor.SelectionDeviceEnum toSelDevice,
                                                  Inventor.RadialMarkingMenu toRadialMenu, Inventor.NameValueMap toAddInfo)
        {
            if (toSelDevice == Inventor.SelectionDeviceEnum.kGraphicsWindowSelection)
            {
                toRadialMenu.EastControl = this.oApp.CommandManager.ControlDefinitions["AppContextual_CancelCmd"];
                toRadialMenu.WestControl = this.oApp.CommandManager.ControlDefinitions["AppContextual_ContinueCmd"];
            }
        }

 The menu is correctly shown , command " AppContextual_CancelCmd" send Esc to events, but I have no idea how to catch "AppContextual_ContinueCmd". is this possible?

 

Thank you,

Petr

0 Likes
1,102 Views
4 Replies
Replies (4)
Message 2 of 5

YuhanZhang
Autodesk
Autodesk

You can use the event UserInputEvents.OnActivateCommand.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 3 of 5

petrxn
Advocate
Advocate

Thank you for the tip, but this does not work. I have tried to catch these command, but this event is not fired.

I also tried to create my own button, but I have found that I do not understand how the definition works. If I define button in class (constructor), first time when I call this class everything is ok, but if I call this class second time and more, then I get error as attached. It seems that definition is not "live" with the class, but is still in memory and is not possible to define the same button again. What is the correct way? To define all possible buttons in addin constructor? Or is there way to destroy definition?

 

Many thanks for help

 

0 Likes
Message 4 of 5

YuhanZhang
Autodesk
Autodesk

The error seems happening is because of you are attempting to create the same control definition twice, to avoid this you can check if a control definition already exists before creating it. There are several samples in Inventor SDK, you can find them after you install the DeveloperTools.msi(like in win7, after installing the DeveloperTools, you can get the samples in C:\Users\Public\Documents\Autodesk\Inventor 20xx\SDK\DeveloperTools\Samples), and an addin named SimpleAddin maybe an expmple for you to learn how to create control definitions and when to destroy them.

 

Hope this helps.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 5 of 5

petrxn
Advocate
Advocate

Thank you,  finally I have made my class Disposable and in Dispose() method I delete these button definitions. Now seems that it works as I expect.

 

Cheers,

0 Likes