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: 

OnSelect event when selecting a component in a drawing view

3 REPLIES 3
Reply
Message 1 of 4
henrik.rudstrom
582 Views, 3 Replies

OnSelect event when selecting a component in a drawing view

Hello, 

Im trying to catch the event when the user selects a component in a drawing view using

CommandManager.UserInputEvents.OnContextMenu += UserInputEvents_OnContextMenu;

But it seems that the onselect event only catches selection of drawing views or balloon, annotation etc, but not the component inside the drawing view is this intentional or a bug?

 

The reason i need to catch this is to make a new context menu action, so i need the selected item. I know i can use SelectionSet, but i want to be able to debug my application as an external application connecting to the running instance before i build it into an addin (saves me a lot of inventor restarts..) And Selection Set does not seem to work when i use it inside an event handler in an external application... 

 

Thanks

 

Henrik

 

 

3 REPLIES 3
Message 2 of 4

On further thought, using SelectSet will not work in any case, as i also need to know the position the user clicked and possibly modify the preselection. 

 

Any hints would be very much appreciated!

 

Message 3 of 4

Update:

Tried to look more into using SelectSet object in the OnContextMenu event. When i right click on a part in a drawing (after setting selection Part Priority), the selectset contains one item, but i have no idea what type the object has. 

 

i tried checking for various types, see code below, and in visual studio it only tells me it is a System.__COMObject with one property: Type, which has a numeric value: 2130706445

 

Anyone have an idea what type of object this is?

 

 

public void UserInputEvents_OnContextMenu(SelectionDeviceEnum SelectionDevice, NameValueMap AdditionalInfo, CommandBar CommandBar)
{
var a = AddinGlobal.InventorApp.ActiveDocument.SelectSet[1];
if(a is PartDocument)
      Debug.WriteLine(((PartDocument)a).DisplayName);
if(a is PartComponentDefinition)
     Debug.WriteLine(((PartComponentDefinition)a).Document.DisplayName);
if (a is ComponentOccurrence)
{
     var co = (ComponentOccurrence)a;
     Debug.WriteLine(((PartComponentDefinition)co.Definition).Document.DisplayName);
}
if (a is DocumentDescriptor)
{
     var dd = (DocumentDescriptor)a;
    Debug.WriteLine(dd.ReferencedDocumentType);
}
}

Message 4 of 4

Hi,

 

about checking object type, two ways you could use. Please refer to the code below. Hope helps.

 

Sub test()

'assume you got an object from the event Dim oObj As Object 'way1 If TypeOf oObj Is ComponentOccurrence Then End If 'way2 Dim objType As ObjectTypeEnum objType = oObj.Type If objType = kComponentOccurrenceObject Then End If End Sub

 

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

Post to forums  

Autodesk Design & Make Report