Imports System.Runtime.InteropServices
Public Class Form1
Private Sub SetDocumentToGageTableAssociation_Click(sender As Object, e As EventArgs) Handles SetDocumentToGageTableAssociation.Click
Dim objApplication As SolidEdgeFramework.Application = Nothing
Dim objSMDoc As SolidEdgePart.SheetMetalDocument = Nothing
Dim myMatTable As SolidEdgeFramework.MatTable = Nothing
Dim bUseNFFromExcel As Boolean = True
Dim bAddAssociation As Boolean = True
Dim strInputGage As String = "16 gage"
Dim strInutGageTable As String = "Stainless Steel"
Try
objApplication = Marshal.GetActiveObject("SolidEdge.Application")
' Get the material table object from the application
myMatTable = objApplication.GetMaterialTable()
objSMDoc = objApplication.ActiveDocument
If (objSMDoc Is Nothing) Then
MsgBox("Failed to get Sheet Metal Document object.")
End If
MsgBox("Adding 'Document to Gage Table' Association!")
Call myMatTable.SetDocumentToGageTableAssociation(objSMDoc, strInputGage, strInutGageTable, bUseNFFromExcel, bAddAssociation)
MsgBox("Removing 'Document to Gage Table' Association!")
bUseNFFromExcel = False
bAddAssociation = False
strInputGage = ""
strInutGageTable = ""
Call myMatTable.SetDocumentToGageTableAssociation(objSMDoc, strInputGage, strInutGageTable, bUseNFFromExcel, bAddAssociation)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
public class Form1
{
private void SetDocumentToGageTableAssociation_Click(object sender, EventArgs e)
{
SolidEdgeFramework.Application objApplication = null;
SolidEdgePart.SheetMetalDocument objSMDoc = null;
SolidEdgeFramework.MatTable myMatTable = null;
bool bUseNFFromExcel = true;
bool bAddAssociation = true;
string strInputGage = "16 gage";
string strInutGageTable = "Stainless Steel";
try
{
objApplication = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application");
// Get the material table object from the application
myMatTable = objApplication.GetMaterialTable();
objSMDoc = objApplication.ActiveDocument;
if (objSMDoc == null)
{
MessageBox.Show("Failed to get Sheet Metal Document object.");
}
MessageBox.Show("Adding 'Document to Gage Table' Association!");
myMatTable.SetDocumentToGageTableAssociation(objSMDoc, strInputGage, strInutGageTable, bUseNFFromExcel, bAddAssociation);
MessageBox.Show("Removing 'Document to Gage Table' Association!");
bUseNFFromExcel = false;
bAddAssociation = false;
strInputGage = "";
strInutGageTable = "";
myMatTable.SetDocumentToGageTableAssociation(objSMDoc, strInputGage, strInutGageTable, bUseNFFromExcel, bAddAssociation);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}