Anonymous
in reply to:
Anonymous
06-29-2016
10:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
06-29-2016
10:39 AM
The code below seems to work fine with an assembly file.
Sub Main()
Dim oApp As Inventor.Application
oApp = ThisApplication
If ThisApplication.ActiveDocumentType <> kAssemblyDocumentObject Then
MessageBox.Show("ERROR - Active Document is not an assembly document!","iLogic Error")
Exit Sub
End If
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
MessageBox.Show("ASSEMBLY DOCUMENT!","iLogic Debug")
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
End Sub