Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
in reply to: Anonymous

Hi,

 

Here in VBA. This changes material for each component if material is "Aluminium" to "Steel". You can modify your code from this. This also skips standard content center components.Material will be changed for custom content center components.


Dim oApp As Inventor.Application
Set oApp = ThisApplication

Dim oDoc As AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument

 

Dim strMaterialNameToChange As String
strMaterialNameToChange = "Aluminium"

 

Dim strNewMaterialName As String
strNewMaterialName = "Steel"

 

Dim oOcc As ComponentOccurrence
For Each oOcc In oDoc.ComponentDefinition.Occurrences.AllLeafOccurrences

       If oOcc.Definition.Material.name = strMaterialNameToChange And oOcc.Definition.IsContentMember = False Then
             oOcc.Definition.Material = oDoc.Materials.Item(strNewMaterialName)
       End If

Next