- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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 Subcould somebody please help me out on this?
Thanks best regards
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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:
but if i click the IPT in my assembly only a few of the fields get filled in. why?
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
in code is :
tan_Nachbearbeitung
in screen you have:
tan_Nachberbeitung
i dont see:
wec_Schweißbaugruppe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report