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,

 

There is a problem in this red line.. It simply closes the Inventor without changing any material.

 

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.AllLeafOccurr​ences

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

Next

 

I don't know the exact issue. but, Do I need to include any object library?

 

Sukpal