Material Assets

Material Assets

woodstylee3
Advocate Advocate
434 Views
3 Replies
Message 1 of 4

Material Assets

woodstylee3
Advocate
Advocate

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

 

0 Likes
435 Views
3 Replies
Replies (3)
Message 2 of 4

Frederick_Law
Mentor
Mentor

The only place I can find a value for Weld is:

In document.MaterialAssests[Item].["physmat_classification"], the value is "Autodesk.Material Classifications.Metal.Weld"

 

Not sure if that's what you need.

Watch.jpg

0 Likes
Message 3 of 4

woodstylee3
Advocate
Advocate
I'll take a look thanks, none of my materials have that classification, but if I try to assign (by accident) a weld material to a part component definition, an exception is thrown
0 Likes
Message 4 of 4

Frederick_Law
Mentor
Mentor

I have all my metal set to Weldable so I can switch weldment with any material.

Part can use any material, weldment can only use weldable material.

0 Likes