Jump to content

Open AutoCAD Using C#


Bill Tillman

Recommended Posts

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 AcadDocument
Try
           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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...