SOLIDWORKS API C# Standalone その1 入門編 とりあえずC#でSOLIDWORKSとつなげてみる! 音声なし、、、日本語字幕でどうぞ
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using SolidWorks.Interop.sldworks;
namespace SW_csharp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SldWorks swApp = null;
ModelDoc2 swDoc = null;
try
{
swApp = (SldWorks)Marshal.GetActiveObject("Sldworks.Application.31");
}
catch
{
swApp = null;
return;
}
string rNum = swApp.RevisionNumber();
MessageBox.Show(rNum);
swDoc = (ModelDoc2)swApp.ActiveDoc;
if(swDoc == null) { return; }
string pName = swDoc.GetPathName();
MessageBox.Show(pName);
}
}
}
コメント