Solid Edge Framework Type Library
GetMaterialListFromLibrary Method
Specify name of Material Library as string from which you want to get material list.
Returns total number of materials as integer.
Returns list of materials as an array.
Description
This API will return the list of materials from a specific library. The library can be full path or only name of the library file.
Syntax
Visual Basic
Public Sub GetMaterialListFromLibrary( _
   ByVal bstrLibraryName As String, _
   ByRef plNumMaterials As Long, _
   ByRef listOfMaterials As Variant _
) 
Parameters
bstrLibraryName
Specify name of Material Library as string from which you want to get material list.
plNumMaterials
Returns total number of materials as integer.
listOfMaterials
Returns list of materials as an array.
Example
Imports System.Runtime.InteropServices

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim objApp As SolidEdgeFramework.Application = Nothing
        Dim objType As Type = Nothing
        Dim objMatTable As SolidEdgeFramework.MatTable = Nothing
        Dim strLibrary As String = "Materials"
        Dim objDocument As SolidEdgePart.PartDocument = Nothing
        Dim strMessage As String
        Dim strMaterial As String
        Dim varGetPropVal As Object = Nothing
        Dim varSerPropVal As Object = Nothing
        Dim listOfMaterials As Object = Nothing
        Dim numMaterials As Long
        Try
            ' Get SE handle
            objApp = Marshal.GetActiveObject("SolidEdge.Application")

            If objApp Is Nothing Then
                ' Get the type from the Solid Edge ProgID
                objType = Type.GetTypeFromProgID("SolidEdge.Application")
                ' Start Solid Edge
                objApp = Activator.CreateInstance(objType)
                ' Make Solid Edge visible
                objApp.Visible = True
            End If


            ' Get material table object handle
            objMatTable = objApp.GetMaterialTable()

            ' Get document handle
            objDocument = objApp.Documents.Add("SolidEdge.PartDocument")



            'Get material list
            objMatTable.GetMaterialListFromLibrary(strLibrary, numMaterials, listOfMaterials)

            strMessage = String.Format("Number of materials -->{0}", numMaterials)
            MsgBox(strMessage)
            strMaterial = listOfMaterials(5)
            strMessage = String.Format("5th Material is --> {0}", strMaterial)
            MsgBox(strMessage)

        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

    End Sub

End Class
See Also

MatTable Object  | MatTable Members