Sure. The code just needs to get a bit longer to accomplish that. Here is an example iLogic rule that will first make sure that the active document is an assembly, and if not will let the user know, then exit the rule. Then it gets to the collection of all the top level components in the assembly. Then it starts looping/iterating through those components, one at a time, checking a few things. If it is suppressed, skips to next component. If it does not represent a part, skip to next component. If it is not a Content Center member, skip to next component. Then it uses that same iLogic snippet to access the custom iProperty of that component, using its exact name (which it gets from the actual component). But you still have to edit the property name once in the code before running it. Then it shows you a message which includes the name of the component, and the value of the custom iProperty, so you know which one it is referring to. Then, at the 'Next' line, it goes back to the next component, if there are more.
Sub Main
'check to make sure an assembly is currently active, or else it will not work
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("An Assembly must be active for this iLogic rule to work. Exiting.", vbCritical, "iLogic")
Exit Sub 'this line exits the rule
End If
'get a reference to the currently open/active assembly document
Dim oADoc As AssemblyDocument = ThisDoc.Document
'get a reference to its component definition (contains all the geometry, features, & components)
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
'get a reference to the components collection (top level components only)
Dim oOccs As ComponentOccurrences = oADef.Occurrences
'if there are no components in the assembly, exit the rule
If oOccs.Count = 0 Then Exit Sub
'start looping/iterating through each component in the collection
For Each oOcc As ComponentOccurrence In oOccs
'if the component is suppressed, then skip to next component
If oOcc.Suppressed = True Then Continue For
'if the component does not represent a Part, then skip to next component
If TypeOf oOcc.Definition Is PartComponentDefinition = False Then Continue For
Dim oOccPDef As PartComponentDefinition = oOcc.Definition
'If it is not a Content Center member, then skip to next component
If oOccPDef.IsContentMember = False Then Continue For
Dim oPropValue As Object = Nothing 'variable to hold the value
' <<< !!! EDIT THE PROPERTY NAME HERE !!! >>>
oPropValue = iProperties.Value(oOcc.Name, "Custom", "PropertyName")
'show a message to the user with some information
MsgBox("Component Name = " & oOcc.Name & vbCrLf & _
"Property Value = " & oPropValue.ToString, vbInformation, "iLogic")
Next 'oOcc 'now the code goes to the next component, if there are more
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)