Managing events at a per-document level

By Philippe Leefsma

Q:

I need to keep track of events such as Database.ObjectAppended, Database.ObjectModified at a per-document level for all documents opened, created and existing in AutoCAD.

What is the best way to achieve this through the .Net API?

A:

The attached VB.Net sample illustrates how to achieve this:

The idea is to create a custom class, called PerDocController in my example, that will be responsible for holding the events at a per-document level.

The command class is then holding a dictionary of <Document, PerDocController> pairs for each loaded document.

The events DocumentActivated and DocumentToBeDestroyed are then used to keep this dictionary up-to-date.

The complete code is provided in the attached project.


Comments

One response to “Managing events at a per-document level”

  1. Thanks Good Sample

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading