Req vb.net code to select component from drawing model browser and store the occurance name

Req vb.net code to select component from drawing model browser and store the occurance name

vishnuteja14
Contributor Contributor
212 Views
5 Replies
Message 1 of 6

Req vb.net code to select component from drawing model browser and store the occurance name

vishnuteja14
Contributor
Contributor

Hello 

 

I added a addin button in inventor drawing file i need help to write a vb.net code which helps me to select the component from drawing model browser tree and get the occurance name 

 

So I can use it for view creations of those components

0 Likes
213 Views
5 Replies
Replies (5)
Message 2 of 6

marcin_otręba
Advisor
Advisor

Hi,

 

For start, what it should do ? could you explain it ?

 

you can start from onselect event to get your occurrence from node here is documentation:

 

Inventor 2022 Help | SelectEvents.OnSelect Event | Autodesk

 

or here:

marcin_otrba_0-1732274425383.png

 

 

declare UserInterfaceEvents:

Private WithEvents m_uiEvents As UserInterfaceEvents

set it in activate method:

m_uiEvents = g_inventorApplication.UserInterfaceManager.UserInterfaceEvents

and then it shloud me somethng like this:

Private Sub OnDocumentSelectedEvent(JustSelectedEntities As Inventor.ObjectsEnumerator, ByRef MoreSelectedEntities As Inventor.ObjectCollection, SelectionDevice As Inventor.SelectionDeviceEnum, ModelPosition As Inventor.Point, ViewPosition As Inventor.Point2d, View As Inventor.View) Handles oUserInputEvents.OnSelect
            If SelectionDevice = SelectionDeviceEnum.kBrowserSelection Then
                If JustSelectedEntities.Count = 1 Then
                    Dim onode As BrowserNode
                    Dim occ As ComponentOccurrence
                    Try
                        onode = JustSelectedEntities(1)
                        occ = onode.NativeObject
                    Catch ex As Exception
                        onode = Nothing
                    End Try
                End If
            End If
end sub

 

 

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 3 of 6

vishnuteja14
Contributor
Contributor

I am looking trying to select components from drawing browser tree using vb.net command manager.pock selectkenum but it doesn't select any component so I need code to select component

0 Likes
Message 4 of 6

marcin_otręba
Advisor
Advisor

i posted one to do it.

Pick method will not work.

 

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 5 of 6

vishnuteja14
Contributor
Contributor

I am unable to select in first place I think the code which you posted is to store the entity after selection .

I am looking for code to select the component in first place

0 Likes
Message 6 of 6

marcin_otręba
Advisor
Advisor

if you will do it corectly this code will get component occurrence from selected node.

than you can use it as you wish.

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes