.NET

Reply
Active Member
Davidgun64
Posts: 9
Registered: ‎11-09-2011
Message 1 of 3 (77 Views)
Accepted Solution

Help with getting code to run with DoccumentActivated

77 Views, 2 Replies
11-19-2011 07:06 AM

Hello

 

I am trying to get some code to run whenever the active documents changes.  As far as I can tell the code below should run when I load my app however it does not.  I was able to get similar code to run copied from the .net devlopers guide but thier example involved the user runing a command to run the AddHandler part which is not what i want.

 

any help is appreciated.

 

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices

Public Class CurrentDrawing
    Implements IExtensionApplication


    Public Sub Initialize() Implements IExtensionApplication.Initialize
        AddHandler Application.DocumentManager.DocumentActivated, AddressOf docColDocAct
    End Sub

    Public Sub Terminate() Implements IExtensionApplication.Terminate

    End Sub

    Public Sub docColDocAct(ByVal senderObj As Object, ByVal docColDocActEvtArgs _
                            As DocumentCollectionEventArgs)
        Application.ShowAlertDialog(docColDocActEvtArgs.Document.Name & " was activated.")
    End Sub

End Class

 

Hi,

 

you have created a class that is derived from IExtensionApplication but AutoCAD will not call it. So you are missing the part that tells AutoCAD that there is an initialization-part.

Practically this means you have to add this line under your imports:

 

<Assembly: Autodesk.AutoCAD.Runtime.ExtensionApplication(GetType(CurrentDrawing))>

 

The red part may have to be exchanged to the fill NameSpace-name of your class-definition-name. With this statement AutoCAD knows there is an initialization part to run and it will do that when you NETLOAD your app.

 

- alfred -

*Expert Elite*
Alfred.NESWADBA
Posts: 9,099
Registered: ‎06-29-2007
Message 2 of 3 (73 Views)

Re: Help with getting code to run with DoccumentActivated

11-19-2011 08:03 AM in reply to: Davidgun64

Hi,

 

you have created a class that is derived from IExtensionApplication but AutoCAD will not call it. So you are missing the part that tells AutoCAD that there is an initialization-part.

Practically this means you have to add this line under your imports:

 

<Assembly: Autodesk.AutoCAD.Runtime.ExtensionApplication(GetType(CurrentDrawing))>

 

The red part may have to be exchanged to the fill NameSpace-name of your class-definition-name. With this statement AutoCAD knows there is an initialization part to run and it will do that when you NETLOAD your app.

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Active Member
Davidgun64
Posts: 9
Registered: ‎11-09-2011
Message 3 of 3 (71 Views)

Re: Help with getting code to run with DoccumentActivated

11-19-2011 08:15 AM in reply to: Davidgun64

Thanks!  got it working now.

Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.