So, something like this?
Dim oCurrentDoc As Inventor.Document
Dim oDoc As Inventor.Document
Dim oPartDoc As PartDocument
Dim oRefDoc As DocumentsEnumerator
Dim oTargetColor As RenderStyle
Dim oNewColor As RenderStyle
oCurrentDoc = ThisApplication.ActiveDocument
If oCurrentDoc.DocumentType = kAssemblyDocumentObject Then
For Each oDoc In oCurrentDoc.AllReferencedDocuments
If oDoc.DocumentType = kPartDocumentObject Then
oPartDoc = oDoc
If oPartDoc.ComponentDefinition.Material.Name = "Plywood"
oNewColor = oPartDoc.RenderStyles.Item("Clear")
If Not oPartDoc.ActiveRenderStyle Is oNewColor Then
oPartDoc.ActiveRenderStyle = oNewColor
End If
End If
End If
Next
End If
This one searches for a Material called "Plywood" and will change the active render style to "Clear". The other code would have done the same thing, but would have looked for the color of the Material rather than the Material itself (though it did require you to swap out the two text names for the RednerStyles for the ones that you were using / wanted to change).
Out of curiosity, Instead of making a color Clear, why not just turn off the visibility of the part?
Also, if you're messing with the visibility of a certain group of parts, why not just create a view representation of the assembly with all of those items turned off? You could even put a Custom iProperty on each part that identifies which View Rep it should go to, and have code go through each part setting it to where it needs to go. This would give you automation plus, possibly, sexier assemblies.
Any who, I hope that this runs for you correctly.
If my solution worked or helped you out, please don't forget to hit the kudos button 🙂iLogicCode Injector:
goo.gl/uTT1IB