Drawings SDK Developer Guide > Working with .dwg Files > Working with Entities > Working with Associative Arrays > Associative Arrays Architecture
Associative Arrays Architecture

Associative arrays are implemented through the following mechanisms:

  • Two anonymous Block Table Records (BTRs).
  • BlockReference in model space.
  • OdDbAssocAction, OdDbAssocArrayParameters, and OdDbAssocDependency classes.

Two anonymous BTRs

When an associative array is implemented through two BTRs, the first (source) BTR stores the source entities. Array items are represented with block references pointing to the source BTR. Those references are stored in the second (destination) anonymous BTR.

Associative array BTRs in the database hierarchy

In the picture above, the source entity is stored in the U2 block, and array items are stored in the U3 block.

Block reference in model space

In model space, an associative array is implemented with a block reference to the destination BTR.

Associative array with block reference to destination BTR

In model space, the AcDbDictionary object stores a block reference pointing to the U3 block. This block contains the destination BTR (as described in Two anonymous BTRs).

OdDbAssocAction, OdDbAssocArrayParameters, and OdDbAssocDependency classes

The base class that provides the associative behavior is the OdDbAssocAction class. This class stores the value parameters of the array (rows, columns and levels count, spacing between array entities, etc.) and provides the evaluate() method for handling all changes.

Note that the OdDbAssocAction class has no virtual methods that can be overridden, therefore it can't be used for deriving and alternating association implementations.

OdDbAssocAction is the base class for such classes as:

  • OdDbAssocNetwork — Class representing the network of associated actions.
  • OdDbAssocActionBody — Abstract base class for deriving custom action body.

The OdDbAssocParamBasedActionBody class is derived from OdDbAssocActionBody and represents the associated parameter based on the action body. It is the parent class for OdDbAssocArrayActionBody.

The OdDbAssocArrayActionBody class implements an array of associated actions which can be evaluated for locating and managing the items of an associative array. It contains common functionality for all types of associative arrays:

  • Static method createInstance() to create new associative arrays.
  • Static method isAssociativeArray() to check if an entity is an associative array.
  • Static method getControllingActionBody() to obtain the Id of OdDbAssocArrayActionBody for a given entity.
  • Method getArraySourceBTR() to modify the source BTR.
  • Array item defaults (depending on array type) and relative transforms in destination anonymous BTR.

Any association can have parameters that determine its type and reaction for changing items. The base abstract class which implements the interface for an array of associated parameters is OdDbAssocArrayParameters. Common associated parameters are in the OdDbAssocArrayCommonParameters class.

The following classes are inherited from OdDbAssocArrayCommonParameters:

  • OdDbAssocArrayRectangularParameters
  • OdDbAssocArrayPolarParameters
  • OdDbAssocArrayPathParameters

These classes are designed to control the parameters of associative arrays according to their types: rectangle, polar, or path.

The OdDbAssocDependency class is the base class that represents the dependency.

The dependency stores a list of action objects. An action object either depends on an entity of the database or modifies it. In other words, dependency determines how associativity is represented in the drawing database. Dependencies are attached to the entities as persistent reactors and are owned by the action object. When the entity that is depended on is changed, it notifies the dependency through the persistent reactor mechanism.

The OdDbAssocDependency object stores several softPointRef objects:

  • Array Entity (blockRef in model space).
  • Source BTR (BTR containing all the source entities).
  • Destination BTR (BTR with blockRefs to the source BTR, representing array items).
  • Path Entity (path array items are arranged along a path entity).

The OdDbAssocDependency object acts as a reactor for all objects listed above. The evaluate() method checks whether any changes were made in the source entities and updates those entities.

Dependency as a reactor for associative array items

Classes derived from OdDbAssocDependency:

  • OdDbAssocGeomDependency — Implements a dependency on a subentity (face/edge/vertex) of a geometric object. It stores a subentity ID which persistently identifies the subentity and provides a protocol to get and set the referenced subentity geometry.
  • OdDbAssocValueDependency — Represents a dependency on a scalar value, which is the same as a dependency on a numerical variable.

See Also

Working with Associative Arrays

Creating Associative Arrays

Editing Associative Array Parameters

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