About Working with Reactors in Multiple Namespaces (AutoLISP/ActiveX)

AutoLISP does provide limited support for reactor callback functions executing in a document that is not active.

Note: ActiveX support in AutoLISP is limited to Windows only.

AutoLISP works in single drawing document at a time, while some AutoCAD APIs, such as ObjectARX and VBA, do support the ability for an application to work simultaneously in multiple documents. As a result, an application may modify an open drawing that is not currently active.

While AutoLISP applications cannot run outside the active document, they can be ran in a separate-namespace from the document it is loaded from, but it is still associated with that document and cannot manipulate objects in another document.

By default, a reactor callback function will execute only if a notification event occurs when the document it was defined in is the active document. You can alter this behavior using the vlr-set-notification function.

If you want a reactor to execute its callback function even if the document it is not active (for example, if an application in another namespace triggers an event), use the following function call:

(vlr-set-notification reactor-object 'all-documents)

If you want a reactor to only execute its callback function if an event occurs when the document it was defined in is active, use the following function call:

(vlr-set-notification reactor-object 'active-document-only)

The vlr-set-notification function returns the specified reactor object.

For example, the following statements define a reactor and sets it to respond to events whether or not its associated document is active:

(setq circleReactor (vlr-object-reactor (list myCircle) "Circle Reactor"
'((:vlr-modified . print-radius))))
#<VLR-Object-Reactor>

(vlr-set-notification circleReactor 'all-documents)
#<VLR-Object-Reactor>

The notification setting of a reactor can be determined with the vlr-notification function. For example:

(vlr-notification circleReactor)
all-documents

The vlr-set-notification function affects only the specified reactor. All reactors are created with the default notification set to active-document-only.

Caution: If you choose to set a reactor to execute its callback function even if triggered when its document is not active, the callback function should do nothing other than set and read AutoLISP variables. Any other action may cause the system to become unstable.