public static void Launch_Autocad()
{
// "AutoCAD.Application.16.2" uses 2006
// "AutoCAD.Application.17" uses 2007 or 2008, whichever was most recently run
// "AutoCAD.Application.17.1" uses 2008, specifically
// "AutoCAD.Application.18" uses 2010
const string progID = "AutoCAD.Application.17.1";
AcadApplication acApp = null;
try
{
acApp = (AcadApplication)Marshal.GetActiveObject(progID);
}
catch
{
try
{
Type acType = Type.GetTypeFromProgID(progID);
acApp = (AcadApplication)Activator.CreateInstance(acType, true);
}
catch
{
MessageBox.Show("Cannot create object of type \"" +progID + "\"");
}
}
if (acApp != null)
{
try
{
// By the time this is reached AutoCAD is fully
// functional and can be interacted with through code
acApp.Visible = true;
//Here you can call AutoCAD functions or interact with a dll based on OBJECTARX and COM registered
}
catch (System.Exception ex)
{
MessageBox.Show("Problem executing component: " + ex.Message);
}
}
}