This is a similar scenario, but gets the materials from an actual asset library, instead of from the current document. You just need to edit the name of the library, or edit the full file name of your library file for it to open and source the materials from.
Dim oMatList As New List(Of String)
Dim oALibs As AssetLibraries = ThisApplication.AssetLibraries
Dim oLib As AssetLibrary
Try
oLib = oALibs.Item("MyMatLibName")
Catch
oLib = oALibs.Open("FullFileNameOfLibraryFile")
Catch
MsgBox("Could not find that material library.", vbCritical, "")
Exit Sub
End Try
If IsNothing(oLib) Then Exit Sub
Dim oMAs As AssetsEnumerator = oLib.MaterialAssets
If oMAs.Count = 0 Then Exit Sub
For Each oMA As MaterialAsset In oMAs
oMatList.Add(oMA.DisplayName)
Next
Dim oChosenMatName As String
oChosenMatName = InputListBox("", oMatList, oMatList.Item(0), "Materials", "List Of Materials")
Dim oChosenMat As MaterialAsset = oMAs.Item(oChosenMatName)
MsgBox("oChosenMat.DisplayName = " & oChosenMat.DisplayName,,"")
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)