Here is a rule that will update material of derived component from the appearance of the Parent solid body. I would test this on a small non production assembly to ensure it is working as it should be.

Dim Doc As Document = ThisDoc.Document
If Doc.DocumentType = kPartDocumentObject Then
MessageBox.Show("This rule can only be run in an assembly file - exiting rule", "iLogic")
Return
End If
For Each RefDoc As Document In Doc.AllReferencedDocuments
'Look at ony part files.
If RefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
Dim RefPartDoc As PartDocument = RefDoc
'Logger.Info(RefPartDoc.DisplayName)
Dim DPComps As DerivedPartComponents = RefPartDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents
For Each DPComp As DerivedPartComponent In DPComps
'Logger.Info(DPComp.ReferencedDocumentDescriptor.FullDocumentName)
For Each Sb As ReferenceFeature In DPComp.SolidBodies
' Logger.Info(Sb.Name)
' Logger.Info(Sb.Appearance.Name)
'[Bring the correct material to the part. Appearance names must match material Names, if not use option filter!
Dim MaterialName As String = Sb.Appearance.DisplayName
'Option Filter: If Appearance names don't match material Names.
'Dim MaterialName As String = "Gold"
'If Sb.Appearance.DisplayName = MaterialName Then
' 'Create Reference To another material Library
' Dim AssetLib As AssetLibrary = ThisApplication.AssetLibraries.Item("Inventor Material Library")
' 'Set The Active Library
' ThisApplication.ActiveMaterialLibrary = AssetLib
'Create Reference To the active material Library.
Dim AssetLib As AssetLibrary = ThisApplication.ActiveMaterialLibrary
Dim LocalMaterial As MaterialAsset
Try
Try
LocalMaterial = RefPartDoc.MaterialAssets.Item(MaterialName)
Catch Ex As Exception
Dim LibMaterial As MaterialAsset = AssetLib.MaterialAssets.Item(MaterialName)
LibMaterial.CopyTo(RefPartDoc)
LocalMaterial = RefPartDoc.MaterialAssets.Item(MaterialName)
End Try
RefPartDoc.ActiveMaterial = LocalMaterial
Catch Ex As Exception
Logger.Info("No Material available")
End Try
RefPartDoc.Update
']
'End If
Next
Next
End If
Next
Doc.Update
In addition here is an optional rule to derive the parent part and make an assembly. This automates the make components command.
Sub Main()
'Set a reference to the active partdocument
Dim ParentDoc As PartDocument = ThisDoc.Document
'Dim DPTemplate As String = "C:\Templates\SHEET METAL.ipt"
Dim DPTemplate As String = Nothing
'Set the folder for the new files
Dim Folder As String = ThisDoc.Path
'Create an object collection to store the parts to put in assembly
Dim PartCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
For Each Sb As SurfaceBody In ParentDoc.ComponentDefinition.SurfaceBodies
'Create a new part to derive the solid body in.
Dim PartDoc As PartDocument = ThisApplication.Documents.Add(kPartDocumentObject,DPTemplate, True)
'Set a reference to the derivedpartcomponents.
Dim Dpcs As DerivedPartComponents = PartDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents
'Create the scale definition.
Dim Dpd As DerivedPartUniformScaleDef = Dpcs.CreateUniformScaleDef(ParentDoc.FullFileName)
'Set the Derived Part settings.
DerivedPartSettings(Dpd, Sb)
Dpcs.Add(Dpd)
PartCol.Add(PartDoc)
'Set the part title to the solidbodies name.
PartDoc.PropertySets.Item("Inventor Summary Information").Item("Title").Value = Sb.Name
' Save the part
ThisApplication.SilentOperation = True
Try
PartDoc.SaveAs(Folder & "\" & Sb.Name & ".ipt", False)
Catch
End Try
ThisApplication.SilentOperation = False
Next Sb
'Use a template for a new assembly.
'Dim AssyDoc As AssemblyDocument = ThisApplication.Documents.Add(kAssemblyDocumentObject,, True)
'Find opened assembly in which the sketch part is.
Dim AssyDoc As AssemblyDocument = ThisApplication.Documents.Open(Folder & "\House" & ".iam")
'Place in assembly.
For Each PartDoc In PartCol
' create an empty matrix
Dim mx As Matrix = ThisApplication.TransientGeometry.CreateMatrix()
Dim Occ As ComponentOccurrence = AssyDoc.ComponentDefinition.Occurrences.AddByComponentDefinition(PartDoc.ComponentDefinition, mx)
PartDoc.Close(True)
Next
End Sub
Sub DerivedPartSettings(ByRef Dpd As DerivedPartUniformScaleDef, Sb As SurfaceBody)
'Set the derive style.
Dpd.ExcludeAll
'Include solid, exclude the others
For Each Dpe As DerivedPartEntity In Dpd.Solids
If Dpe.ReferencedEntity.Name = Sb.Name Then
Dpe.IncludeEntity = True
End If
Next
End Sub
If this solved a problem, please click (accept) as solution.
Or if this helped you, please, click (like)
Regards
Alan