- 积分
- 22862
- 明经币
- 个
- 注册时间
- 2016-5-25
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
搬运http://www.theswamp.org/index.php?topic=49944.0
- class 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.");
- }
- }
- }
- }
|
|