Extended data (xdata) is the functional equivalent of MicroStation's element linkage. Extended data can be attached to any entity and consists of a data entries preceded by "group codes" that denote their type. The order of these group codes implies the application ownership - an application precedes it group data with its application ID and any data following that ID and up to the next application ID belongs to that application. Except for beginning with an application ID, the order and content of the extended data is determined by the application. The group code values are completely described in the AutoCAD documentation, but the more common values are defined in msdefs.h as follows:
An application can add extended data to an element with the mdlLinkage_addXDataGroupCode function as demonstrated in the code fragment below (from the example application dwgappdata)
The extended data created by this code fragment would appear in a DWG file as follows:
Similarly, an application can look for extended data on an element with mdlLinkage_findApplicationXData. If the element contains extended data for the supplied application then the function returns success and the index of that application's extended data.
The extended data can then be read by repeatedly calling mdlLinkage_getXDataGroupCode to extract each the individual group codes and their associated data. See the dwgappdata application for an example of that illustrates the extraction of extended data.
Extended Records (xrecords) are the DWG equivalent of MicroStation's application (type 66, level 20) elements. They are similar to extended data in that they contain a series of data chunks with the data type denoted by a group code. They also provide similar functionality of XAttributes.
In order to locate extended records or other objects a DWG file contains a series of "Dictionary Objects". A dictionary contains a series of entries that contain a name and the ID of an element associated with that entry. An application will typically add an extended dictionary to a file that contains entries for each of its extended records. The application's extended dictionary is located by an application supplied, unique name in the file's main dictionary. The mdlDictionary_findDictionary function can be used to find an application dictionary. The mdlDictionary_extractEntry function can then be used to extract the dictionary entries.
Once a dictionary element is located, it's data can be extracted by using the mdlXRecord_extractGroupData and mdlXRecord_getGroupCode functions. See the dwgappdata application for an example that demonstrates this process.