Demand Loading on Detection of Custom Objects

When a DWG or DXF file containing custom objects is loaded, AutoCAD determines whether or not the associated application is loaded. If the application is not loaded, and the first bit of the system variable DEMANDLOAD is set, AutoCAD searches the Windows system registry for information about the application and its loader module. If AutoCAD finds the appropriate information in the system registry, it loads the application.

Note: Demand loading on detection of custom classes will only work with classes that are derived from AcDbObject, either directly or indirectly.

As a hypothetical example, let's assume that AutoCAD reads a file created by the ObjectARX application polysamp (a product of PolySamp Inc.).

  1. Upon reading the drawing file, AutoCAD encounters custom objects created with the application polysamp, and determines that the application is not loaded.
  2. AutoCAD finds that the DEMANDLOAD system variable is set to enable demand loading of applications on proxy detection, so it searches the AutoCAD Applications section of the system registry for the polysamp key. Within this key, it finds the LOADCTRLS value, which defines the conditions under which the application should be loaded. This section of the registry would look something like this:

\\HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\ObjectDBX\<VERSION>\Applications\<Application>
            DESCRIPTION:REG_SZ:PolyCad
            LOADCTRLS:REG_DWORD:0xd
            LOADER:REG_SZ:C:\Program Files\polysampinc\polyui.dbx
 
AutoCAD reads the polysamp\LOADER key to determine the directory, path, and file name of the module to be loaded.

AutoCAD then attempts to load the ObjectARX module. If the module loads successfully, AutoCAD adds the application's handle to the list of application handles to be sent the kLoadDwgMsg message. AutoCAD then verifies that the application has been loaded properly, and verifies that the custom class is registered. If the application was loaded successfully, AutoCAD will continue to load the drawing file. If the ObjectARX module cannot be loaded, or if there still isn't a class implementation available, custom objects are treated as proxies and the load continues.