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,

Some Error comes in the Red line  Method 'Material' of object 'PartComponentDefinition' failed

 

Private Sub CommandButton2_Click()
Dim oApp As Inventor.Application
Set oApp = ThisApplication

Dim oDoc As AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument

Dim strMaterialName As String
strMaterialName = "1.4307"

Dim oOcc As ComponentOccurrence
For Each oOcc In oDoc.ComponentDefinition.Occurrences.AllLeafOccurrences
       oOcc.Definition.Material = oDoc.Materials.Item(strMaterialName)
Next

End Sub