Comparison of Symbol Tables and Dictionaries

Symbol tables and dictionaries perform essentially the same function; they contain entries that are database objects that can be looked up using a text string key. You can add entries to these container objects, and you can use an iterator to step through the entries and query their contents.

The AutoCAD database always contains a fixed set of nine symbol tables, described in the following section. You cannot create or delete a symbol table, but you can add or change the entries in a symbol table, which are called records. Each symbol table contains only a particular type of object. For example, the AcDbLayerTable contains only objects of type AcDbLayerTableRecord. Symbol tables are defined in this manner mainly for compatibility with AutoCAD Release 12 and previous releases of AutoCAD.

Dictionaries provide a similar mechanism for storing and retrieving objects with associated name keys. The AutoCAD database creates the named object dictionary whenever it creates a new drawing. The named object dictionary can be viewed as the master “table of contents” for the nonentity object structures in a drawing. This dictionary, by default, contains nine dictionaries: the GROUP dictionary, the MLINE style dictionary, the layout dictionary, the plot style name dictionary, the color dictionary, the material dictionary, the plot settings dictionary, the table style dictionary, and the SYSVAR dictionary. You can create any number of additional objects and add them to the named object dictionary. However, the best practice is to add one object directly to the named object dictionary and have that object in turn own the other objects associated with your application. Typically, the owning object is a container class such as a dictionary. Use your assigned four-letter Registered Developer Symbol for the name of this class.

An AcDbDictionary object can contain any type of AcDbObject, including other dictionaries. A dictionary object does not perform type checking of entries. However, the MLINE style dictionary should contain only instances of class AcDbMlineStyle, and the GROUP dictionary should contain only instances of AcDbGroup. An application may require specific typing for entries in a dictionary that it creates and maintains.

The class hierarchy for symbol tables, symbol table records, dictionaries, and iterators is as follows.

An important difference between symbol tables and dictionaries is that symbol table records cannot be erased directly by an ObjectARX ® application. These records can be erased only with the PURGE command or selectively filtered out with wblock operations. Objects owned by a dictionary can be erased.

Danger: Erasing dictionaries or dictionary entries (see Essential Database Objects) probably will cause AutoCAD or other applications to fail.

Another important difference is that symbol table records store their associated look-up name in a field in their class definition. Dictionaries, on the other hand, store the name key as part of the dictionary, independent of the object it is associated with, as shown in the following figure.