Bill Tillman 发表于 2022-7-6 22:08:57

Open AutoCAD Using C#

For the last few years I've been using this code in VB.NET to open a drawing in AutoCAD. This works great and it looks for an existing instance to use before opening a new one:

       Dim vAcadApp As AcadApplication       Dim vAcadDoc As AcadDocumentTry         If Process.GetProcessesByName("acad").Length > 0 Then               vAcadApp = GetObject(, "AutoCAD.Application.19")         Else               vAcadApp = New AcadApplication         End If         vAcadApp.Visible = True         vAcadApp.WindowState = AcWindowState.acMax         vAcadDoc = vAcadApp.Documents.Open(DwgPath & DwgName, True)
We've now begun working more with C# so I'm searching for how to do this very same thing but in C#.
 
And there is one other caveat on this I must deal with. This will be run at the users' desktop and we have various versions of AutoCAD running. Some 2009's sprinkled here and there but mostly 2013 and 2014. I'm fearing that this will make loading the appropriate reference a complicated task.
页: [1]
查看完整版本: Open AutoCAD Using C#