Announcements
Notice: Upload of PDF documents is currently unavailable across the Community due to an ongoing issue.

How to Get Document Object from Context Menu?

How to Get Document Object from Context Menu?

mfoster9TD82
Advocate Advocate
650 Views
2 Replies
Message 1 of 3

How to Get Document Object from Context Menu?

mfoster9TD82
Advocate
Advocate

Hello,
Does anyone know a way to get the selected Document object from the Browser in a OnContextMenu event?

 

Snag_3368dd84.png


I made a custom context menu button, but I can't figure out how to get the selected Document object from the context menu user event

private void UserInputEvents_OnContextMenu(SelectionDeviceEnum SelectionDevice, NameValueMap AdditionalInfo, CommandBar CommandBar)
{ ...}

 or from the button click event

 private void CCIFSInfoRightClick_OnExecute(NameValueMap Context)
 {...}

 
Anyone have any insights or ideas?

0 Likes
Accepted solutions (2)
651 Views
2 Replies
Replies (2)
Message 2 of 3

C_Haines_ENG
Collaborator
Collaborator
Accepted solution

Wow I had no clue you could add your own context menu items!

 

I don't code in VBA and I'm guessing based on how I think this action would go. I only see:

 

UserInputEvents.OnLinearMarkingMenu( SelectedEntities As ObjectsEnumerator, SelectionDevice As SelectionDeviceEnum, LinearMenu As CommandControls, AdditionalInfo As NameValueMap )

 

You would be looking for an event that had "SelectedEntities as ObjectEnumerator" in it. If you have that firing correctly and its getting one object, I assume that it will be a kBrowserNodeObject. You can get the object with .NativeObject. This will get the componentoccurrence you selected. 

 

You should definitely post the whole code though.

Message 3 of 3

mfoster9TD82
Advocate
Advocate
Accepted solution

Good find! I was using UserInputEvents.OnContextMenu which doesn't look like it is in the API documentation anymore...
I figured out a way to do it with OnContextMenu, you can just look at 

InventoInventorApplication.ActiveDocument.SelectSetrApplication.ActiveDocument.SelectSet

But I think the OnLinearMarkingMenu is probably the more supported method so I'll probably switch to using that, It looks like they do about the same thing. 

0 Likes