Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: ngnam1988

Hi @ngnam1988.  The object you are most likely returning from your Pick method is a ComponentOccurrence, not a Document object.  The ComponentOccurrence object does not directly have a 'PropertySets' property, that is only accessible from a Document type object.  There are a few ways to access the iProperties that are associated with an assembly component, but none of them are direct, the way you have it there.  If going the API way, similar to what you have above, then you will need to get the Document that the assembly component represents first, then you can use that Document to access the iProperties from.  There are two ways to get the Document from a component:

 - ComponentOccurrence.ReferencedDocumentDescriptor.ReferencedDocument

 - ComponentOccurrence.Definition.Document

Or, if the component is a 'top level' one (not within a sub assembly), you may be able to use the iLogic shortcut snippet iProperties.Value(ComponentOccurrence.Name, "PropertySetName", "Property.Name") to access it.

Edit:  Below is an example of one way to alter your code.

Dim AssemblyDOC As AssemblyDocument = _InventorApp.ActiveDocument
Dim ITEM = _InventorApp.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select an Item")
If (Not ITEM Is Nothing) Then
	Dim oComp As ComponentOccurrence = ITEM 'or try to Cast it to correct Type
	Dim oCompDoc As Document = oComp.ReferencedDocumentDescriptor.ReferencedDocument
	Dim ITEMPropertySets As PropertySets = oCompDoc.PropertySets
	Dim ITEMPropertySet As PropertySet = ITEMPropertySets.Item("Design Tracking Properties")
	Dim ITEMPartNumber As Inventor.Property = ITEMPropertySet.Item("Part Number")
	MsgBox("THE PART NUMBER: " & ITEMPartNumber)
End If

Wesley Crihfield

EESignature

(Not an Autodesk Employee)