Extract iProperty information directly from an occurence

Extract iProperty information directly from an occurence

shastu
Advisor Advisor
494 Views
2 Replies
Message 1 of 3

Extract iProperty information directly from an occurence

shastu
Advisor
Advisor

I know how to extract iProperty information from a file that is open.  What I am wanting to do is be able to capture the iProperty information of a part that is selected in an assembly.  Similar to how I can get the name of the occurrence with:

    Dim oSS As SelectSet
    Set oSS = oDoc.SelectSet

 OccurrenceName= oSS.Item(1).Name

 

I want to be able to get the Part Number, Stock Number, and Description iProperties of that occurrence

0 Likes
Accepted solutions (1)
495 Views
2 Replies
Replies (2)
Message 2 of 3

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@shastu,

 

Try below VBA code to extract iPorperty information from selected occurrence.

Sub FindiProperties()
    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oSS As SelectSet
    Set oSS = oDoc.SelectSet

    Dim occ As ComponentOccurrence
    On Error GoTo Exception
    Set occ = oSS.Item(1)
    
    Dim oReferDoc As Document
    Set oReferDoc = occ.ReferencedDocumentDescriptor.ReferencedDocument
    
    Dim oPartNo As String
    Dim oStockNo As String
    Dim oDesc As String
    
    oPartNo = oReferDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Expression
    oStockNo = oReferDoc.PropertySets.Item("Design Tracking Properties").Item("Stock Number").Expression
    oDesc = oReferDoc.PropertySets.Item("Design Tracking Properties").Item("Description").Expression
    
Exception:
    If Err.Number = 13 Then
        MsgBox ("Selected object is not occurrence")
    End If
End Sub

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 3 of 3

shastu
Advisor
Advisor

Thanks so much.  I appreciate it greatly.

0 Likes