外部启动CAD

mac2022-06-30  100

static void Main(string[] args) { // 连接至 AutoCAD 应用程序 RegistryKey RegK = Registry.LocalMachine; RegistryKey software = RegK.OpenSubKey("Software\\Autodesk\\AutoCAD\\R17.1", false); if (software == null) { Console.WriteLine("AutoCAD 2008启动失败!"); return; } // 判断注册表文件是否已经存在 //if (IsReg) //{ Console.WriteLine("注册表文件已存在,AutoCAD 2008正常启动.."); //Console.ReadLine(); System.Type AcadType = System.Type.GetTypeFromProgID("AutoCAD.Application"); Object acad= System.Activator.CreateInstance(AcadType); AcadType.InvokeMember("visible", System.Reflection.BindingFlags.SetProperty, null, acad, new object[] { true }); Object documents = AcadType.InvokeMember("Documents", System.Reflection.BindingFlags.GetProperty, null, acad, null); Object document = documents.GetType().InvokeMember("Add", System.Reflection.BindingFlags.InvokeMethod, null, documents, null); //Autodesk.AutoCAD.Interop.AcadApplicationClass ICad = new AcadApplicationClass(); //ICad.Visible = true; //ICad.WindowState =Autodesk.AutoCAD.Interop. //return; //} } // 注册表文件是否存在 static bool IsReg { get { RegistryKey Key = Registry.LocalMachine.OpenSubKey("Software\\Autodesk\\AutoCAD\\R17.1\\ACAD-6002:804\\Applications\\SmartSoft", false); if (Key == null) return false; Key.Close(); return true; } } }

转载于:https://www.cnblogs.com/chinaHunk/archive/2011/01/09/1931333.html

相关资源:外部.NET程序与AutoCAD交互
最新回复(0)