Message 1 of 17
Accessing AcadDocument and AcadApplication via .NET assembly

Not applicable
05-12-2009
03:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Wondering if someone could please tell me what is the equivalent code of my COM accessing code below in .NET assembly?
For many years the code below has given me the results I needed but now I was told that I have to use .NET AutoCAD assemblies
instead and rewrite the code shown below so that it would use all the rich features provided via AutoDesk.AutoCAD.ApplicationServices.
In a nutshell, my code below allows me to grab an existing instance of AutoCAD or create a new one if no instance of AutoCAD is open then grabs the active AutoCAD document for my use. Thank you so much for all the kind help you could give
Gratefully,
Matt
My code is shown below:
Public ThisDrawing as Autodesk.AutoCAD.InterOp.AcadDocument
Public Sub CreateOrGetAutoCADinstance
Dim acadApp as Autodesk.AutoCAD.InterOp.AcadApplication
On Error Resume Next
acadApp = GetObject(, "AutoCAD.Application")
If Err.Number Then
acadApp = CreateObject("AutoCAD.Application")
End If
acadApp.Visible = True
ThisDrawing = acadApp.ActiveDocument
End Sub
For many years the code below has given me the results I needed but now I was told that I have to use .NET AutoCAD assemblies
instead and rewrite the code shown below so that it would use all the rich features provided via AutoDesk.AutoCAD.ApplicationServices.
In a nutshell, my code below allows me to grab an existing instance of AutoCAD or create a new one if no instance of AutoCAD is open then grabs the active AutoCAD document for my use. Thank you so much for all the kind help you could give
Gratefully,
Matt
My code is shown below:
Public ThisDrawing as Autodesk.AutoCAD.InterOp.AcadDocument
Public Sub CreateOrGetAutoCADinstance
Dim acadApp as Autodesk.AutoCAD.InterOp.AcadApplication
On Error Resume Next
acadApp = GetObject(, "AutoCAD.Application")
If Err.Number Then
acadApp = CreateObject("AutoCAD.Application")
End If
acadApp.Visible = True
ThisDrawing = acadApp.ActiveDocument
End Sub