- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
OK. I understand better now.
Dealing with representations within an assembly, can get tricky. Especially if trying to handle it all by code and trying to maintain the 'Associative' setting of component view representations at deeper levels. Keep in mind that if any sub-assemblies are associatively set to a certain view representation, it might not like it when this code attempts to turn off visibility of a component within that sub-assembly. You may need to set sub-assemblies to certain view representations too, in order to achieve your goals. Just something to think about.
Yes, you can check the component's Part Number for that text. Here is an updated rule that retrieves the Part Number from each component. Then checks to make sure it isn't blank/empty, then checks to see if it contains the specified data. If it passes both checks it will turn visibility of that component off.
Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
For Each oLeafOcc As ComponentOccurrence In oADef.Occurrences.AllLeafOccurrences
If iProperties.Value(oLeafOcc.Name, "Custom", "type") = "CNC machined" Then
oLeafOcc.Visible = True
ElseIf iProperties.Value(oLeafOcc.Name, "Custom", "type") = "laser" Then
oLeafOcc.Visible = False
End If
'If iProperties.MaterialOfComponent(oLeafOcc.Name) = "Steel" Then
' oLeafOcc.Visible = False
'End If
Dim oPN As String = iProperties.Value(oLeafOcc.Name, "Project", "Part Number")
If String.IsNullOrEmpty(oPN) = False AndAlso oPN.Contains("DIN 933") Then
oLeafOcc.Visible = False
End If
Next
Wesley Crihfield
(Not an Autodesk Employee)