Drawings SDK Developer Guide > Working with .dwg Files > Working with Databases > Working with Extended Data > Concept of Extended Data
Concept of Extended Data

Extended data (or XData) is a data set that is used by an external application, and it is stored in the database together with an object to which the data belongs. An external application defines how to use its own data set within the extended data and must be registered in the database. The database stores the names of all registered applications in the special predefined table. Several applications can attach their own data to a single object. Data of several objects can belong to a single application.

Extended data consists of tagged pairs (group code – data value) which are divided into sequences. Each sequence is associated with the registered application to which it belongs. A group code defines the data type and work practices for processing the data value. A data value is the content which must correspond to the group code. A group code can define a string value, real value, integer value, handle, layer name, binary chunk, or 3D point. Each tagged pair is implemented by a resbuf-object. Extended data organizes the resbuf-instances in a dynamically linked list named xdata-sequence.

Each sequence must begin with a special group code 1001 that specifies the start of the current sequence and associates it with a registered application. The end of the current sequence is the start of the next sequence or the end of the extended data. All resbuf-instances between special group codes 1001 are related to one sequence and one application. Additionally, extended data must also start with the special group code 1001. If the special group code is absent from the beginning of the extended data, errors occur. The maximum size of extended data attached to one object is 16K per application.

The special group code 1001 stores the name of the registered application associated with the sequence. The name of the application must be unique in the database and must be registered in the special table of the database. Methods use the specific group codes and application names to correspond to the registered application. If an application is not registered, errors occur.

Tagged data within a sequence can be united in data blocks. Each block defines a logical data set within a sequence. Blocks can be nested. Only the application that is associated with a sequence is aware of the block destinations. The control group code 1002 specifies a data block within a sequence. The start of the block is indicated when the value of the control group code 1002 is "{" and the end of the block is indicated with the value "}". The number of 1002 "{" group codes must equal the number of the1002 "}" group codes for a sequence.

The database interface has the following methods to manipulate extended data:

  • GetXData() — Reads extended data attached to an object for the associated application or for all applications. The method requires the application name as an optional argument and returns the sequence of resbuf-instances.
  • SetXData() — Writes extended data for for all applications. The method requires a pointer to the sequence of resbuf-instances as an argument and does not return a value.

See Also

Working with Extended Data

Available XData Group Codes

Example of Entering and Displaying the Group Code and Data Value for XData

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