Imports System
Imports System.Runtime.InteropServices
Namespace Examples
Friend Class Program
<STAThread>
Shared Sub Main(ByVal args() As String)
Dim application As SolidEdgeFramework.Application = Nothing
Dim partDocument As SolidEdgePart.PartDocument = Nothing
Dim materialTable As SolidEdgeFramework.MatTable = Nothing
Try
' See "Handling 'Application is Busy' and 'Call was Rejected By Callee' errors" topic.
OleMessageFilter.Register()
' Attempt to connect to a running instance of Solid Edge.
application = DirectCast(Marshal.GetActiveObject("SolidEdge.Application"), SolidEdgeFramework.Application)
partDocument = CType(application.ActiveDocument, SolidEdgePart.PartDocument)
materialTable = application.GetMaterialTable()
materialTable.SetActiveDocument(partDocument)
Dim materialName = "MyMaterial"
Dim libraryName = "Materials"
Dim materialsPath = "Others"
Dim faceStyle = "Copper"
Dim fillStyle = "ANSI33(Brass)"
' Define exactly 9 material properties in this specific order (pay attention to the units!!):
' 1) Density [kg/m3]
' 2) Coef. of Thermal Exp. [1/ºC]
' 3) Thermal Conductivity [W/mºC]
' 4) Specific Heat [J/kgºC]
' 5) Modulus of Elasticity [Pa]
' 6) Poisson's Ratio[unitless]
' 7) Yield Stress [Pa]
' 8) Ultimate Stress [Pa]
' 9) Elongation % [unitless]
Dim propList = New Object() { 7888.0, 0.0, 51.0, 500.0, 69985996255.0, 711.0, 250000000.0, 745000000.0, 0.0 }
materialTable.AddMaterialToLibrary(materialName, libraryName, materialsPath, propList.Length, propList, faceStyle, fillStyle)
materialTable.DeleteMaterialFromLibrary(materialName, libraryName)
Catch ex As System.Exception
Console.WriteLine(ex)
Finally
OleMessageFilter.Unregister()
End Try
End Sub
End Class
End Namespace
using System;
using System.Runtime.InteropServices;
namespace Examples
{
class Program
{
[STAThread]
static void Main(string[] args)
{
SolidEdgeFramework.Application application = null;
SolidEdgePart.PartDocument partDocument = null;
SolidEdgeFramework.MatTable materialTable = null;
try
{
// See "Handling 'Application is Busy' and 'Call was Rejected By Callee' errors" topic.
OleMessageFilter.Register();
// Attempt to connect to a running instance of Solid Edge.
application = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application");
partDocument = (SolidEdgePart.PartDocument)application.ActiveDocument;
materialTable = application.GetMaterialTable();
materialTable.SetActiveDocument(partDocument);
var materialName = "MyMaterial";
var libraryName = "Materials";
var materialsPath = "Others";
var faceStyle = "Copper";
var fillStyle = "ANSI33(Brass)";
// Define exactly 9 material properties in this specific order (pay attention to the units!!):
// 1) Density [kg/m3]
// 2) Coef. of Thermal Exp. [1/ºC]
// 3) Thermal Conductivity [W/mºC]
// 4) Specific Heat [J/kgºC]
// 5) Modulus of Elasticity [Pa]
// 6) Poisson's Ratio[unitless]
// 7) Yield Stress [Pa]
// 8) Ultimate Stress [Pa]
// 9) Elongation % [unitless]
var propList = new object[] { 7888.0, 0.0, 51.0, 500.0, 69985996255.0, 711.0, 250000000.0, 745000000.0, 0.0 };
materialTable.AddMaterialToLibrary(materialName, libraryName, materialsPath, propList.Length, propList, faceStyle, fillStyle);
materialTable.DeleteMaterialFromLibrary(materialName, libraryName);
}
catch (System.Exception ex)
{
Console.WriteLine(ex);
}
finally
{
OleMessageFilter.Unregister();
}
}
}
}