documentation on how to connect to autocad from an exe in vb.net

documentation on how to connect to autocad from an exe in vb.net

Anonymous
Not applicable
1,565 Views
4 Replies
Message 1 of 5

documentation on how to connect to autocad from an exe in vb.net

Anonymous
Not applicable

Where is the documentation on how to connect to autocad from an exe in vb.net?

 

The ObjectARX is not appropriate, and the standard VBA code doesn't works.

 

I had spent hours trying to find how to replace "ThisDrawing" (=autocad drawing on VBA) on a VB.NET project to create a new layer.

 

I cannot find the VB.NET way of doing ThisDrawing.Layers.Add(layerName)

0 Likes
Accepted solutions (1)
1,566 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

Here it says

 


@StephenPreston wrote:

The .NET equivalent of ThisDrawing is Application.DocumentManager.mdiActiveDocument.Database. The Database class has a Filename property that returns the DWG filepath and name.


but that's only available from ObjectARX, which cannot be accessed from an EXE

0 Likes
Message 3 of 5

norman.yuan
Mentor
Mentor

Well, I am not a fan of using EXE to control AutoCAD, as I said in other post, here is the usual way to do it:

 

Dim cadApp As AcadApplciation = Nothing

Dim doc As AcadDocument = Nothing

 

Try

  '' Connect to existing AutoCAD session

  cadApp=GetObject(, "AutoCAD.Application")

Catch

  '' If no existing AutoCAD session, start one

  Try

    cadApp = CreateObject("AutoCAD.Application")

  Catch

    MsgBox("Cannot connect to AutoCAD!")

    Return

  End Try

End Try

 

doc=cadApp.Documents.Open("c:\....\myDrawingh.dwg"....)

 

Now you have the AcadDocument that is equivalent to ThisDrawing in VBA. Do whatever you want to, as you do in AutoCAD VBA, just be aware of the syntext different from VB.NET and VBA.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 4 of 5

Anonymous
Not applicable

Ok, but where is the documentation?

0 Likes