Anonymous
in reply to:
Anonymous
02-25-2016
07:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
02-25-2016
07:18 AM
' Get the active assembly document.
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
' Get the material to assign to all of the parts.
Dim strMaterialName As String
strMaterialName = "YOUR MATERIAL HERE"
Dim oMaterial As Material
On Error Resume Next
' Try to get the material of the specified name.
oMaterial = oAsmDoc.Materials.Item(strMaterialName)
On Error Goto 0
' Iterate through all of the documents refrenced by the assembly.
Dim oDoc As Document
For Each oDoc In oAsmDoc.AllReferencedDocuments
' Check to see if this is a part.
If oDoc.DocumentType = kPartDocumentObject Then
Dim oPartDoc As PartDocument
oPartDoc = oDoc
' Set the material.
oPartDoc.ComponentDefinition.Material = oMaterial
End If
NextThis could be a start for you.
Run in an assembly it will assign all components the same material.