发送命令加载lisp
搬运http://www.theswamp.org/index.php?topic=49944.0class LaunchAutoCAD
{
private static IAcadApplication vAcadApp = null;
private static IAcadDocument vAcadDoc = null;
private static string vAcadID = "AutoCAD.Application.20";
public static void StartAutoCAD()
{
try
{
// Check for instance of AutoCAD
vAcadApp = (IAcadApplication)System.Runtime.InteropServices.Marshal.GetActiveObject(vAcadID);
}
catch (Exception) // None found so start a new instance of AutoCAD
{
Type AcadProg = Type.GetTypeFromProgID(vAcadID);
vAcadApp = (IAcadApplication)System.Activator.CreateInstance(AcadProg);
}
if (vAcadApp != null)
{
vAcadApp.Visible = true;
vAcadDoc = vAcadApp.Documents.Open(myDrawingTemplate.dwg", true);
vAcadDoc.SendCommand("(load \"" + LispPath + "myLisp.lsp\" \"The load failed\") ");
vAcadDoc.SendCommand(LISPVariables.PrepareAcadCmd() + " ");
vAcadDoc.SendCommand("(setq svPath \"" + (ReadDefaults.vsSaveAutoDwgPath).Replace("\\", "/") + "\") ");
vAcadDoc.SendCommand("(setq *erp 1) ");
vAcadDoc.SendCommand("startLisp ");
}
else
{
Console.WriteLine("ERROR: The drawing file is missing.");
}
}
}
} 太难了,看不懂
页:
[1]