.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
how to access AutoCAD 2012 from Vb.net Standard Exe
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
hi
is that possible to access AutoCAD 2012 from VB.net Standard Exe
i am using vb.net 2010
i try to load AcDbMgd.dll and AcMgd every time i compile it give error in "Imports
Autodesk.AutoCAD.ApplicationServices"
is there any example for read and write current open drawing in AutoCAD from .net Standard Exe.
Thanks in advance.
Amrit
Re: how to access AutoCAD 2012 from Vb.net Standard Exe
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
http://through-the-interface.typepad.com/through_t

“We don’t have a snowball’s chance in a blast furnace of surviving this attack unless every one of our units gets into the fight right now!”
Re: how to access AutoCAD 2012 from Vb.net Standard Exe
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
i don't understand
Re: how to access AutoCAD 2012 from Vb.net Standard Exe
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Sorry I read your question wrong.
acDbMgd.dll and AcMgd are only for internal use within Autocad. They can't be used by an outside EXE.
Get a reference to COM Autocad 2012 Type Library
Imports System
Imports System.Runtime.InteropServices
Imports Autodesk.AutoCAD.Interop
Public Class ComCode
Public Sub runme()
Const progID As String = "AutoCAD.Application.18"
Dim acApp As AcadApplication = Nothing
Try
acApp = DirectCast(Marshal.GetActiveObject(progID), AcadApplication)
Catch ex As Exception
Try
Dim acType As Type = Type.GetTypeFromProgID(progID)
acApp = DirectCast(Activator.CreateInstance(acType, True), AcadApplication)
Catch ex2 As Exception
MessageBox.Show("Cannot create object of type """ & progID & """")
End Try
End Try
If acApp IsNot Nothing Then
' By the time this is reached AutoCAD is fully
' functional and can be interacted with through code
End If
End Sub
End Clas

“We don’t have a snowball’s chance in a blast furnace of surviving this attack unless every one of our units gets into the fight right now!”
Re: how to access AutoCAD 2012 from Vb.net Standard Exe
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
hi arcticad
thanks for reply
it look like it is connect with autocad. but how to draw object and how to select object on it. could you please give little hints.
thnaks
Re: how to access AutoCAD 2012 from Vb.net Standard Exe
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Sub dwgAddCircle(ByVal acadApp As Autodesk.AutoCAD.Interop.AcadApplication)
Dim doc As AcadDocument = acadApp.ActiveDocument
Dim pt(2) As Double
pt(0) = 0
pt(1) = 0
pt(2) = 0
doc.ModelSpace.AddCircle(pt, 10)
End Sub
Sub dwgReSave(ByVal acadApp As Autodesk.AutoCAD.Interop.AcadApplication, ByVal strFileName As String)
Dim acadDBX As Object = acadApp.GetInterfaceObject("ObjectDBX.AxDbDocument .18")
If FileExists(strFileName) Then
If Not InUse(strFileName) Then
Try
acadDBX.Open(strFileName)
acadDBX.saveas(strFileName)
acadDBX = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComO bject(acadApp)
GC.Collect()
GC.WaitForPendingFinalizers()
Catch ex As Exception
End Try
End If
End If
End Sub
Public Function InUse(ByVal sFile As String) As Boolean
If System.IO.File.Exists(sFile) Then
Try
Dim F As Short = FreeFile()
FileOpen(F, sFile, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.LockReadWrite)
FileClose(F)
Catch
Return True
End Try
End If
End Function
Public Function FileExists(ByVal FileFullPath As String) _
As Boolean
Dim f As New IO.FileInfo(FileFullPath)
Return f.Exists
End Function

“We don’t have a snowball’s chance in a blast furnace of surviving this attack unless every one of our units gets into the fight right now!”
Re: how to access AutoCAD 2012 from Vb.net Standard Exe
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
it come error
Unable to cast COM object of type 'System.__ComObject' to interface type 'Autodesk.AutoCAD.Interop.Common.IAcadModelSpace'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{C60BC8AF-58DA-4866-859D-22A7F61411DE}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
in line
doc.ModelSpace.AddCircle(pt, 10)
Re: how to access AutoCAD 2012 from Vb.net Standard Exe
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
hi Arcticad
your code work while i change compiler to 3.5. and when i try to use 4 it give error on draw.
Thanks you
Could any one suggest me what need more in code to draw from exe to autocad while i set to compile option in .net framework 4.
Thanks

