Community
Navisworks API
Welcome to Autodesk’s Navisworks API Forums. Share your knowledge, ask questions, and explore popular Navisworks API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

COM API - Context Menu Item - Focus On Item

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
1515 Views, 5 Replies

COM API - Context Menu Item - Focus On Item

I would prefer to use my own Context Menu rather than the default that fires from the TNWControl but I wish to add the default option “Focus on Item” functionality that exists in the default menu to my own popup menu. Can you tell me how I could perform this option programmatically?

 

I know I can add my own options to the default Context menu, but there are options in the context menu that I don’t wish to display. Maybe there is a way of hiding certain options in the default menu?

5 REPLIES 5
Message 2 of 6
xiaodong_liang
in reply to: Anonymous

Hi, In the past, I have investigated the similar issue. Unfortunately, I did not see a way to disable the contextmenu unless you veto OnContextMenu entirely. This means you cannot fire your own context menu, either. But you can add additional menus to the standard menu, as you have known. The following is a code snippet, in case others want to know how to do. It is based on the SDK sample: ActiveXSimpleExample. ( It looks the forum is problematic, I cannot find the edit menus, so pasting the code directly.) private void axnwControlSDI1_OnUserContextMenuCmd(object sender, AxNavisworksIntegratedAPI9._InwControlEvents_OnUserContextMenuCmdEvent e) { switch (e.cmd_ndx) { case 1: MessageBox.Show("mytest1"); break; case 2: MessageBox.Show("mytest2"); break; case 3: MessageBox.Show("mytest3"); break; case 4: MessageBox.Show("mytest4"); break; case 5: MessageBox.Show("mytest5"); break; } } private void axnwControlSDI1_OnEnableContextMenuCmd(object sender, AxNavisworksIntegratedAPI9._InwControlEvents_OnEnableContextMenuCmdEvent e) { e.bEnable = true; // Event fired to allow addition of custom context menu commands switch (e.cmd_ndx) { case 1: e.display_name = "mytest1"; break; case 2: e.display_name = "mytest2"; break; case 3: e.display_name = "mytest3"; break; case 4: e.display_name = "mytest4"; break; case 5: e.display_name = "mytest5"; break; } } private void axnwControlSDI1_OnContextMenu(object sender, AxNavisworksIntegratedAPI9._InwControlEvents_OnContextMenuEvent e) { //e.bHandled = true; //veto entirely }
Message 3 of 6
Anonymous
in reply to: xiaodong_liang

Hi,

So does that mean I can't replicate the functionality of “Focus on Item”  programmatically?

Message 4 of 6
xiaodong_liang
in reply to: Anonymous

Hi,

what I talked about is whether it is possible to disable the built-in context menu, instead of the functionality itself.

about 'Focus on Item', there is not a direct API, but it is just to move the selected items at the center of the viewpoint. So you can get the boundingbox of the selected item, and change the viewpoint looking at the center of the boundingbox
Message 5 of 6
Anonymous
in reply to: xiaodong_liang

Hi Liang,

Greetings.

 

May I please know if there is any possibility where, I can add a new context menu to a selected object in the tree and as soon as I select my custom context menu, browser should open say, www.google.com and search for the name of the selected object in the search window?

 

It would be really helpful for my work if I am able to achieve this.

 

Thanks in advance for solutions.

 

Best regards

Bangera





 

Message 6 of 6
Pranjal.JAinTM4UU
in reply to: Anonymous

Hi,

 

I am putting another question here instead of the solution. Please help me if you can.

 

I want to customize the context menu that appears when we right click the Saved viewpoint. For reference, I am sharing a Image.


nav 1.png

 

When we right click the Viewpoint, Context Menu appears, I want to perform some custom actions when I click the Viewpoint Name(marked with red color).

Please let me know how to achieve so, if possible, with a code snippet.

 

Thank you.

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report