private void Form1_Load(object sender, EventArgs e)
{
string progID = "AutoCAD.Application.19";
AcadApplication acApp;
AcadApplication vAcadDoc;
if (Process.GetProcessesByName("acad").Length > 0)
{
acApp = (AcadApplication)Marshal.GetActiveObject(progID);
acApp.ActiveDocument.SendCommand("PURGE ");
}
else
{
acApp = new AcadApplication();
acApp = (AcadApplication)Marshal.GetActiveObject(progID);
acApp.ActiveDocument.SendCommand("PURGE ");
}
}