.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help with getting code to run with DoccumentActivated

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Davidgun64
307 Views, 2 Replies

Help with getting code to run with DoccumentActivated

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

 

2 REPLIES 2
Message 2 of 3

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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 3
Davidgun64
in reply to: Davidgun64

Thanks!  got it working now.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost