Material Assets
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have an API, that gathers all material assets from all libraries in the active project, and allows the user to select the material they want from a single drop down. All works, no problems.
However at the moment, when I get materials from the library, I cannot differentiate the materials which are used for parts, from the weldment Materials.
Is there a value on the material asset to check whether each material is for parts or weldments.
If the user selects a weldment material from the drop down, an error occours if they try to apply It to a part file (which I presume is correct). Below my code for recovering the materials from the libraries.
Dim matlist As New System.Collections.Generic.Dictionary(Of Integer, String)
Dim materials As New Generic.List(Of String)
For Each n In GlobalVar.m_inventorApplication.DesignProjectManager.ActiveDesignProject.MaterialLibraries
Dim assetlib As Inventor.AssetLibrary = Nothing
Try
assetlib = GlobalVar.m_inventorApplication.AssetLibraries.Item(n.name)
Catch ex As Exception
Try
assetlib = GlobalVar.m_inventorApplication.AssetLibraries.Open(n.libraryfilename)
Catch EX2 As Exception
assetlib = Nothing
End Try
End Try
'todo: filter out weldment materials, unless Is assy
For Each mtrlasst In assetlib.MaterialAssets
Dim index As Integer = combo.Items.Add(mtrlasst.displayname.ToString)
matlist.Add(index, assetlib.DisplayName)
materials.Add(mtrlasst.displayname.ToString)
Next
' End If
Next
combo.Tag = matlist