My suggestion would be to look at the lab example code as example
code only for demonstrating basic use of the APIs, but do not make
the mistake of taking them as literal examples of how to write real
working or production code.
In this case, the lab example doesn't really demonstrate good coding habits,
especially as it relates to reactors/events. That's because it needlessly
handles both the CommandWillStart and CommandEnded events, which means the
example code is very expensive in terms of performance, and can needlessly
slow
down some operations, like scripting that executes numerous commands.
If your need is to be notified when a specific command or set of commands
starts and ends, the most efficient approach is to handle *only* the
CommandWillStart event. In the handler of that event, if the command that's
starting is one of the commands of interest, then you add a handler to the
CommandEnded event. When you get the CommandEnded notification, you then
remove the handler for that event.
In other words, if the example code were better designed, it would only need
to continuously monitor a single event (CommandWillStart), rather than both
CommandWillStart and CommandEnded.
I don't have anything in VB.NET, but the file at the link below includes C#
sample code along with some reusable classes that are distilled versions of
my actual
working/production code. The samples show one way to more-intelligently deal
with
command-related events.
http://www.caddzone.com/CommandEventsSample.zip
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009
http://www.acadxtabs.com
Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm
wrote in message news:6167469@discussion.autodesk.com...
I have attached some code that I use to catch a command (when it is started
and when it has finished). I took it from the Labs and it works well. In the
code I have made a custom command called "AddEvents". To make the reactors
work I need to run the "AddEvents" command when CAD starts. I do this with a
small lisp program. Is it possible to eliminate the need of running the
"AddEvents" command so that my code is loaded into AutoCAD when it starts
up?