Imports System.Runtime.InteropServices
Public Class Form1
Private Sub AddMaterial_Click(sender As Object, e As EventArgs) Handles AddMaterial.Click
Dim objApplication As SolidEdgeFramework.Application = Nothing
Dim objPartDocument As SolidEdgePart.PartDocument = Nothing
Dim matTable As SolidEdgeFramework.MatTable = Nothing
Dim aMaterials As Object = Nothing
Dim sMatName As String = "Test"
Dim sFaceStyle As String = "Pearl"
Dim sFillStyle As String = "Normal"
Dim sVSStyle As String = "RenderingMtrl"
Dim aMatProps(10) As Long
Dim i As Integer
Try
objApplication = Marshal.GetActiveObject("SolidEdge.Application")
objPartDocument = objApplication.ActiveDocument
matTable = objApplication.GetMaterialTable
'Get the list of all the materials in the material library file
matTable.GetMaterialList(i, aMaterials)
'Set the active document
matTable.SetActiveDocument(objPartDocument)
'Add a new material
matTable.AddMaterial(sMatName, 10, aMatProps, sFaceStyle, sFillStyle, sVSStyle)
'Apply a material
matTable.ApplyMaterial(objPartDocument, sMatName)
'Delete a material
matTable.DeleteMaterial(sMatName)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class