Hi,
Using the Inventor API and vb.,net combination I am able to successfully read an iPropertie and place its value in a textbox inside my vb.net form the code to do so is as follows...
Dim DESTRACKPropSet As Inventor.PropertySet DESTRACKPropSet = Doc.PropertySets.Item("Design Tracking Properties") ' Get the existing property, if it exists. Dim PROPDATE As Inventor.Property = Nothing PROPDATE = DESTRACKPropSet.Item("Creation Time") Dim VALDATE As String = PROPDATE.Value TextBox4.Text = VALDATE
This code will retrive my Creation Time properties value and place its value in textbox4 .
what I understand is that I must select the correct Propertie set in the above example thats "Design Tracking Properties" and I must also know the propertie set item which im trying to access in the above example thats "Creation Time"...
Okay so this all works however now I want to select a custom propertie that i have created in the iproperties.. the Item is named "ARTNR" and its value is set to the text "HELLOthisISaTEST". Based on what Know from the code above I would think that the rightway to access and display my custom ipropertie as follows, however it dosnt work?
' Get the custom property set. Dim CUST2PropSet As Inventor.PropertySet CUST2PropSet = Doc.PropertySets.Item("Inventor User Defined Properties") ' Get the existing property, if it exists. Dim PROPARTNO As Inventor.Property = Nothing PROPARTNO = CUST2PropSet.Item("ARTNR") Dim VALARTNO As String = PROPARTNO.Value TextBox3.Text = VALARTNO
your code looks sound, however for some reason that I forgot, I use a for loop every time I want to locate a property.
Public Function FindiProperty(ByVal PropSetName As String, ByVal PropName As String, ByVal invDoc As Inventor.Document) As Inventor.Property For Each propSet As PropertySet In invDoc.PropertySets If propSet.Name = PropSetName OrElse propSet.InternalName = PropSetName Then For Each prop As [Property] In propSet If prop.Name = PropName Then Return prop End If Next End If Next Return Nothing End Function Public Function GetiPropertyValue(PropSetName As String, PropName As String, invDoc As Inventor.Document) As Object Dim prop As Inventor.Property = FindiProperty(PropSetName, PropName, invDoc) If prop IsNot Nothing Then Return prop.Value Return Nothing End Function
Hi, to get User Defined iProperties I'm ussing this global function:
Public Function iPropertyUser(oDoc As Inventor.Document, oProp As String) As Inventor.Property Dim oPropsets As PropertySets = oDoc.PropertySets Dim oPropSet As PropertySet = oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}") Try iPropertyUser = oPropSet.Item(oProp) Catch oPropSet.Add("", oProp) ' This line will add missing iProperty iPropertyUser = oPropSet.Item(oProp) End Try End Function
You can then use it like this:
Dim VALARTNO As String = iPropertyUser(oDoc, "ARTNR").Expression
Can't find what you're looking for? Ask the community or share your knowledge.