Message 1 of 11
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have already created a command which sets all objects within a selection to a chosen material. It works as I hoped.
Now I am trying to create a command which reverts the objects of a selection back to the 'Generic' material and I cannot seem to get it working.
In both instances I cycle through all the available materials looking for a specific one, but 'Generic' is not found.
Public Sub ScrubKnData() Dim thisDocument As Document = g_inventorApplication.ActiveDocument For Each obj As Object In thisDocument.SelectSet Dim thisMaterialName As String = "Generic Material" Dim thisCompOcc As ComponentOccurrence = obj thisDocument = thisCompOcc.Definition.Document Select Case thisDocument.DocumentType Case DocumentTypeEnum.kPartDocumentObject Dim thisPartDoc As PartDocument = thisCompOcc.Definition.Document Dim theseAssets As AssetsEnumerator = g_inventorApplication.ActiveMaterialLibrary.MaterialAssets For Each thisAsset As Asset In theseAssets If thisAsset.DisplayName = thisMaterialName Then thisPartDoc.ActiveMaterial = thisAsset thisDocument.Update() Exit For End If Next End Select Next End Sub
Any help would be appreciated.
Thanks,
Jeff
Solved! Go to Solution.