I get the instance of autocad thusly
....in Init method of main Class
'create a utility class that grabs Acad's running process and returns via
properties
If m_util Is Nothing Then
m_util = New MCSUtil(True)
m_util.Init2(True)
m_acadApp = m_util.ACAD
m_acadDoc = m_util.AcadDoc
End If
in the utility class...
Public Class MCSUtil
Private m_acadDoc As AcadDocument
Private m_AcadApp As AcadApplication = Nothing
.....
and the Init2 method:
Function Init2(ByVal bDebug As Boolean) As Boolean
m_Debug = bDebug
Try
m_AcadApp = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication
m_acadDoc = m_AcadApp.ActiveDocument
Return True
Catch ex As Exception
Return False
End Try
End Function
///then finalize - i'm wondering if releasing the document is crashing acad?
Protected Overrides Sub Finalize()
m_util = Nothing
m_acadDoc = Nothing
m_acadApp = Nothing
MyBase.Finalize()
End Sub
|