Accessing Property set from an occurance

Accessing Property set from an occurance

sam
Advocate Advocate
1,077 Views
2 Replies
Message 1 of 3

Accessing Property set from an occurance

sam
Advocate
Advocate

Hi, 

I am trying to access a Yes/No property in ("Inventor User Defined Properties") and upon the value of property I need to add further code. I am struggling to get through to it. Any help guiding me will be really appreciated. 

Sub AddStandParts()

Dim oAssyDoc As AssemblyDocument
Dim oPartdoc As PartDocument
Set oAssyDoc = ThisApplication.ActiveDocument
Dim oOccu As ComponentOccurrence
Dim oOccuS As ComponentOccurrences
Set oOccuS = oAssyDoc.ComponentDefinition.Occurrences
For Each oOccu In oOccuS
    Dim invCustomPropertySet As PropertySet
    If oOccu.Definition.Document.ProperSet Then 'Ceartain property set is found, need help here
        MsgBox ("Standard Item")
        Else
        MsgBox ("Custom Item")
    End If
Next
End Sub

 

best regards, 

sam

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

Anonymous
Not applicable
Accepted solution
Sub AddStandParts()

Dim oAssyDoc As AssemblyDocument
Dim oPartdoc As PartDocument
Set oAssyDoc = ThisApplication.ActiveDocument
Dim oOccu As ComponentOccurrence
Dim oOccuS As ComponentOccurrences
Set oOccuS = oAssyDoc.ComponentDefinition.Occurrences
For Each oOccu In oOccuS
    'Dim invCustomPropertySet As PropertySet
    If oOccu.Definition.Document.PropertySets.Item("Inventor User Defined Properties").Item("YourCustomPropertyName").Value = False Then
        MsgBox ("Standard Item")
        Else
        MsgBox ("Custom Item")
    End If
Next
End Sub
Message 3 of 3

sam
Advocate
Advocate

Hello @Anonymous ,

Thank you so much, works perfect. 

Best regards, 

Sam

0 Likes