Close

Relief for ODA Team in Ukraine

Learn more
ODA Drawings SDK
Collecting Database Objects using Dictionaries

The OdDbDictionary class is a dictionary object that represents the interface for storing database objects and manipulating them. The OdDbDictionary class is derived from the OdDbObject class and inherits the standard interface of any database object while expanding it with functionality for working with stored objects. A dictionary can store various objects of different types, custom objects, and other dictionaries. A dictionary can contain an unlimited number of objects. By default, a dictionary can contain predefined objects initially or be empty initially. The dictionary object has the AcDbDictionary class name; the objects of the dictionary can have any class name. Objects of a dictionary must be derived from the OdDbObject class.

The dictionary associates a unique text keyword with each object that it stores. The unique keyword is called the object name. The name is an arbitrary nonempty string that can be up to 255 characters long and can contain letters, digits, blank spaces, underscores, and some special characters, but cannot contain inadmissible letters (see Naming objects). The name is used for identifying, searching, and manipulating the stored objects. The dictionary object is the owner for objects that are stored in it. When an object is added in the dictionary, it gets its own unique ID and the ID of the dictionary object as its Owner ID. To traverse through stored objects, dictionaries use iterators. Iterators allow processing of objects independent from the internal structure of the dictionary and have the semantics and behavior of a pointer that provides additional functionality. Iterators provide a way to traverse through objects of the dictionary and get access to each stored object.

The OdDbDictionaryPtr class is the typified smart pointer to an instance of the dictionary and is used for storing and passing of references to the dictionary object. Objects stored in the dictionary must have their own smart pointer types. The OdDbDictionaryIterator class is the iterator that provides the base interface for unidirectional iterators of the dictionary object and has OdDbDictionaryIterator class name. The OdDbDictionaryIteratorPtr class is the typified smart pointer to the dictionary iterator. The dictionary functionality includes: adding, renaming, and removing objects, iterating through objects, and getting and checking stored objects and names.

The database can contain any number of dictionaries, and dictionaries can be nested one within another. Nested dictionaries form a tree-shape hierarchical structure where one dictionary is the root dictionary that stores other dictionaries as usual objects. The root dictionary associates each sub-dictionary with a unique name which is used as a dictionary identifier. Objects of nested dictionaries get Owner IDs in order of hierarchy. The database initially contains one dictionary as a root for other dictionaries, and this dictionary is called the root drawing dictionary.

The database object can attach a dictionary as a container of extension data, in which case the object is the owner of the dictionary. Such a dictionary can attach custom rendering data to an object for rendering support with a custom photorealistic rendering application or attach custom data for use by another application. Extension dictionaries can contain different objects, including custom objects.

The database stores the following objects as dictionaries: layouts (OdDbLayout), plot settings (OdDbPlotSettings), materials (OdDbMaterial), multi-line styles (OdDbMlineStyle), multi-leader styles (OdDbMLeaderStyle), table styles (OdDbTableStyle), visual styles (OdDbVisualStyle), plot style names (OdDbPlaceHolder), groups (OdDbGroup), colors (OdDbColor), and scales (OdDbScale). The database uses dictionaries for storing of custom objects.

To get the dictionary of specific objects, the database object has the following methods:

  • Layout dictionary — getLayoutDictionaryId();
  • Plot Settings dictionary — getPlotSettingsDictionaryId();
  • Materials dictionary — getMaterialDictionaryId();
  • Multi-line style dictionary — getMLStyleDictionaryId();
  • Multi-leader style dictionary — getMLeaderStyleDictionaryId();
  • Table style dictionary — getTableStyleDictionaryId();
  • Visual style dictionary — getVisualStyleDictionaryId();
  • Plot Style Name dictionary — getPlotStyleNameDictionaryId();
  • Group dictionary — getGroupDictionaryId();
  • Color dictionary — getColorDictionaryId();
  • Scale dictionary — getScaleListDictionaryId();

These dictionaries can have predefined objects which exist initially and cannot be deleted.

Dictionaries give drawings that ability to store objects of different types, add new types of objects, embed custom objects, attach various data to the objects, and flexible restructuring of the database. Usage of dictionaries allows programmers to use one container for manipulating objects of different types. The hierarchical structure of dictionaries allows for dynamic modification and extension of the database structure without restructuring its format.

See Also

Working with Dictionaries of Objects

Root Drawing Dictionary

Collecting Database Objects using Predefined Tables of Named Records

Examples of Using the Record–Table and Dictionary Interfaces

Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.