Message 1 of 19
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a little bit of code and being a novice, complete beginner, cannot understand what is wrong. Please can someone help.
Sub Main()
Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oOccurrence As ComponentOccurrence
' Get the material name to apply to all components
Dim materialName As String = "Stainless Steel"
' Iterate through each component occurrence in the assembly
For Each oOccurrence In oAsmDoc.ComponentDefinition.Occurrences
' Check if the component has a PartDocument
If TypeOf oOccurrence.Definition.Document Is PartDocument Then
Dim oPartDoc As PartDocument = oOccurrence.Definition.Document
Dim currentMaterialName As String = oPartDoc.ComponentDefinition.Material.Name
If currentMaterialName = materialName Then
' Set the material for the component occurrence
oPartDoc.ComponentDefinition.Material.SetMaterial(materialName)
End If
End If
Next
' Save the changes
oAsmDoc.Save()
End Sub
Regards
K.I.S.S. (keep it simple stupid)
Life doesn't have to be complicated.
Designs don't have to be complicated.
GOD Bless you.
Life doesn't have to be complicated.
Designs don't have to be complicated.
GOD Bless you.
Solved! Go to Solution.