access iproperties of "justSelectedEntities"

access iproperties of "justSelectedEntities"

Anonymous
Not applicable
974 Views
10 Replies
Message 1 of 11

access iproperties of "justSelectedEntities"

Anonymous
Not applicable

Hello,

 

I use following sub to detect that a ipt in my Iassembly has been clicked.

if thre is only one selected, i would like to print the part number in a textbox. But I am not able to figure out how to get that information form the "justselectedentities" parameter.

 

 

 Private Sub m_userinputevent_OnSelect(JustSelectedEntities As ObjectsEnumerator, ByRef MoreSelectedEntities As ObjectCollection, SelectionDevice As SelectionDeviceEnum, ModelPosition As Point, ViewPosition As Point2d, View As View) Handles m_userinputevent.OnSelect
            If JustSelectedEntities.Count = 1 Then
                oForm.Auswahl.Visible = True
                oForm.TextBox2.Text = ************** PART NUMBER HERE *************
            Else
                oForm.Auswahl.Visible = False
            End If

        End Sub

could somebody please help me out on this?

 

Thanks best regards

 

 

0 Likes
Accepted solutions (1)
975 Views
10 Replies
Replies (10)
Message 2 of 11

marcin_otręba
Advisor
Advisor

Try:

dim occ as ComponentOccurrence

 

 If TypeOf JustSelectedEntities.Item(1) Is ComponentOccurrence Then

set occ = JustSelectedEntities.Item(1)

end if

 

oForm.TextBox2.Text= occ.name

 

or

 

oForm.TextBox2.Text= occ.definition.document.propertysets.item(3).item("Part Number").value

 

 

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

Message 3 of 11

Anonymous
Not applicable

Thanks, that works... i have a strange problem now tough...

 

i try to write some iproperties to my labels in the form.. this is the code:

 

 

   Private Sub m_userinputevent_OnSelect(JustSelectedEntities As ObjectsEnumerator, ByRef MoreSelectedEntities As ObjectCollection, SelectionDevice As SelectionDeviceEnum, ModelPosition As Point, ViewPosition As Point2d, View As View) Handles m_userinputevent.OnSelect
            If JustSelectedEntities.Count = 1 Then
                oForm.Auswahl.Visible = True

                For Each objEntity As Object In JustSelectedEntities
                    If TypeOf objEntity Is ComponentOccurrence Then
                        'Do whatever you need
                        Dim cmp As ComponentOccurrence = objEntity

                        oForm.AW_Bauteilnummer.Text = cmp.Definition.Document.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value
                        Try
                            oForm.AW_ERP_Nummer.Text = cmp.Definition.Document.PropertySets.Item("Inventor User Defined Properties").Item("ERP_Nummer").Value
                        Catch
                            oForm.AW_ERP_Nummer.Text = ""
                        End Try
                        oForm.AW_Beschreibung.Text = cmp.Definition.Document.PropertySets.Item("Design Tracking Properties").Item("Description").Value
                        Try
                            oForm.AW_Nachbearbeitung.Text = cmp.Definition.Document.PropertySets.Item("Inventor User Defined Properties").Item("tan_Nachbearbeitung").Value
                        Catch
                            oForm.AW_Nachbearbeitung.Text = ""
                        End Try
                        Try
                            oForm.AW_Biegeteil.Text = cmp.Definition.Document.PropertySets.Item("Inventor User Defined Properties").Item("tan_Biegeteil").Value
                        Catch
                            oForm.AW_Biegeteil.Text = ""
                        End Try
                        Try
                            oForm.AW_Schweißbaugruppe.Text = cmp.Definition.Document.PropertySets.Item("Inventor User Defined Properties").Item("wec_Schweißbaugruppe").Value
                        Catch
                            oForm.AW_Schweißbaugruppe.Text = ""
                        End Try

                    End If
                Next
            Else
                oForm.Auswahl.Visible = False
            End If

 

Try catch is used since older files dont have these custom properties.

 

The properties do exist in the file:

 

 

2018-03-20_13h30_19.png

 

but if i click the IPT in my assembly only a few of the fields get filled in. why?

 

 

2018-03-20_14h09_22.png

 

Moreover, if I edit the "biegeteil" value to "True", it still reads false, until i close and reopen the file.. no matter if I un select and reselect it.. is there a way to force it to re load the file with current data? 

 

All i want to do is display those values of the selected file.

 

Thank you

 

0 Likes
Message 4 of 11

marcin_otręba
Advisor
Advisor

Delete For...Next loop it's useless because your code works only if selected obj cout = 1.

Move oForm.Auswahl.Visible = True to the end of If... statement, in the end of filing text boxes.

 

Give me know if it helped...

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 5 of 11

Anonymous
Not applicable

unfortunately it didnt solve the problem. 

 

tried to catch the exception, and for those that dont work it throws this:

 

 

System.Runtime.InteropServices.COMException (0x80004005): Unbekannter Fehler (Ausnahme von HRESULT: 0x80004005 (E_FAIL))
bei System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
bei Inventor.PropertySet.get_Item(Object Index)
bei TanzerFileProp.TanzerFileProp.StandardAddInServer.m_userinputevent_OnSelect(ObjectsEnumerator JustSelectedEntities, ObjectCollection& MoreSelectedEntities, SelectionDeviceEnum SelectionDevice, Point ModelPosition, Point2d ViewPosition, View View) in C:\Users\cad-13\source\repos\TanzerFileProp\TanzerFileProp\StandardAddInServer.vb:Zeile 215.

0 Likes
Message 6 of 11

marcin_otręba
Advisor
Advisor

which line is 215 ?

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 7 of 11

marcin_otręba
Advisor
Advisor

in code is :

 

tan_Nachbearbeitung


in screen you have:

 

 

tan_Nachberbeitung

 

 

i dont see:

 

wec_Schweißbaugruppe

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 8 of 11

Anonymous
Not applicable

oForm.AW_Schweißbaugruppe.Text = odoc.PropertySets.Item("Inventor User Defined Properties").Item("wec_Schweißbaugruppe").Value

 

i checked the exception of only this row. but it will throw the same on the other on etoo..

0 Likes
Message 9 of 11

Anonymous
Not applicable

Found it.. there is a typo in the iproperties... gonna talk to the admin here. 😄 thank you!!!

 

now there still is the problem that if I eidt the data it displays the wrong data until i close and reopen the file.

0 Likes
Message 10 of 11

marcin_otręba
Advisor
Advisor
Accepted solution

did you moved

 

oForm.Auswahl.Visible = True

 

to the end of filling text boxes ?

And checked it after noticing wrong iprops ?

 

i think it should work if you unselect and select (because your code runs on onselect event) it again if you don't have any errors,

 

one more thing... i use on error resume next instead of try catch, you only must be careful when using if statements...

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 11 of 11

Anonymous
Not applicable

works! thank you very muchhhhh!! :))

0 Likes