Event Help

Event Help

Anonymous
Not applicable
459 Views
7 Replies
Message 1 of 8

Event Help

Anonymous
Not applicable
I wanted to create an application event(Acad 2004), so that when a command is executed, the begining of command is used to set the corresponding layer. Can something like this be done? If yes, can someone get me some examples?
0 Likes
460 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
Put all of this code in the ThisDrawing module. Then, vbarun the StartAppEvents sub to instantiate Application level events. The rest should be self-explanatory.

Joe
--

Option Explicit

Dim WithEvents oApp As AcadApplication

Public Sub StartAppEvents()
Set oApp = Application
End Sub

Private Sub oApp_BeginCommand(ByVal CommandName As String)
MsgBox "The " & CommandName & " command just started"
End Sub

Private Sub oApp_EndCommand(ByVal CommandName As String)
MsgBox "The " & CommandName & " command just ended"
End Sub
0 Likes
Message 3 of 8

Anonymous
Not applicable
Thank you Joe, now is it possible to have the StartAppEvents()sub loaded everytime a drawing is opened or a new one is started?
0 Likes
Message 4 of 8

Anonymous
Not applicable
I use a line in my acad.lsp to run mine.

eg. (command "_-vbarun" "ApplicationEvents.InitializeEvents")

Regards - Nathan
0 Likes
Message 5 of 8

Anonymous
Not applicable
Or if you want to stick with vba, create a dvb
called acad.dvb. Then add this to a module.

 

Public Sub AcadStartup ()

    StartAppEvents

End Sub


--
--
Ed
--


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
use a line in my acad.lsp to run mine.
eg. (command "_-vbarun"
"ApplicationEvents.InitializeEvents")
Regards -
Nathan
0 Likes
Message 6 of 8

Anonymous
Not applicable
Thanks Ed, I keep forgetting about that. Regards - Nathan
0 Likes
Message 7 of 8

Anonymous
Not applicable
Ed, I already have a project that is loaded with every drawing. Now, my problem is that when I try copy the code on a module in the project I'm asked for the object, since the thisdrawing object is not used. Can you give me an example of how this works from another project?
0 Likes
Message 8 of 8

Anonymous
Not applicable
Ed, forget about the previous messag. I have a class object with the "Public WithEvents App As AcadApplication" then on a module I have the code + I added the AcadStartup()with the StartAppEvents, but nothing happens. Does the AcadStartup work only from an acad.dvb project? If I copy the code that joe gave on the thisdrawing code, it works fine. I already have a project that contains a lot of macros and I want to keep all macros in one single project. Is it possible to have this run from another project?
0 Likes