Here are answers to questions about MicroStation® Non-Graphic Data that are posted from time to time on the Bentley Discussion Groups. The questions are posted by MDL and VBA developers.
Q Can I store my data (in my case, object name) in a DGN file or model without using an external database?
A There are several technologies that are part of MicroStation by which you can store non-graphical data …
Those different technologies have been introduced to MicroStation over the years. Here's a table showing when each technology was first made available …
| Technology | Introduced with MicroStation | MDL API | VBA API |
|---|---|---|---|
| User Data Linkage | V4 (IGDS) | • | • |
| Database Connectivity | V4 | • | |
| Tag Elements | V5 | • | • |
| XData | V8 (AutoCAD compatibility) | • | • |
| XML Fragments | V8.5 | • | |
| XAttributes | V8i | • |
If you want to correlate this table with your calendar, then see Bentley's summary of the history of MicroStation.
Q
A User data, data linkage and attribute data are the same thing. Bentley uses different terminology to describe the same data.
An element may have multiple user data linkages from more than one application developer. Because each linkage has an application ID, it's easy to distinguish one user data linkage from another.
User data linkages are used for many purposes. Bentley Systems use user data linkages for database linkages, patterning, and other purposes in MicroStation. They use data linkages in their applications that are based on the MicroStation platform.
User data linkages contain unstructured data: the data and their meaning are application-defined. This makes it difficult for a third-party to interpret a user data linkage.
A user data linkage is stored in an array of short (16-bit) words.
Each array contains an application ID, an attribute ID, and a word count, followed by an arbitrary amount of linkage data.
User data linkages can only be accessed by reading and writing the entire
element (that is, the element's data plus all Linkages) together.
Also, there is a maximum size for an element's data plus all it's
linkages (MAX_ELEMENT_SIZE).
The following four diagrams are intended to illustrate the data structure of a DGN element. We don't show any geometric data, since this article discusses the user data linkage …
Here's the LinkageHeader definition from #include file mselems.h
/*----------------------------------------------------------------------+ | | | Linkage Header - Same for all element user data | | | | Use mdlLinkage_getWords/setWords to get/set linkage size. | | | +----------------------------------------------------------------------*/typedef struct { UInt16 wdMantissa:8;/* mantissa words: wtf if wdExponent=0 */UInt16 wdExponent:4;/* exponent for words multiplier */UInt16 user:1;/* boolean: user data linkage */UInt16 modified:1;/* boolean: user linkage modified */UInt16 remote:1;/* boolean: remote linkage */UInt16 info:1;/* boolean: informational linkage */UInt16 primaryID;/* User ID number */} LinkageHeader;
The User ID (primaryID in the above struct) is assigned by Bentley Systems.
The number space of User ID is apportioned between Bentley's own data linkages and those assigned to third-party developers.
Each third-party developer is assigned a unique User ID by Bentley Systems.
For more information about User IDs, you should
contact Bentley Systems.
You should not invent your own User ID other than for testing purposes. If you invent your own User ID it is likely to clash with the User ID assigned by Bentley Systems to another developer. A user will get unpredictable results when using your application if she happens to find an element using the other vendor's supposedly unique User ID.
MicroStation may not know about or care about the data you put into a data linkage, but you do. You may want to store different types of data belonging to different applications. It's usual to to make the first field of your datablock the secondary ID or Application ID. From the API point of view, your Application ID is just another word of data; from your point of view, the Application ID becomes a distinguishing part of every block of user data.
Of course, it's up to you to figure out how to encode and decode your user data. You probably want to write one function that wraps raw data with your Application ID, and another that can extract the Application ID and raw data from a data linkage.
MicroStation can link graphic elements to data stored externally. The external storage is typically a relational database. We don't discuss relational database linkages any further here. For more information, see this page about Database linkages.
XAttributes were introduced with MicroStation V8i. An XAttribute is data that is stored on an element, not in an element. An XAttribute is not part of the element's data. By way of contrast, a user data linkage is part of an element's data.
Both XAttributes and User Data Linkages provide a way for applications to persistently store additional variable length data with an element. The primary distinction between XAttributes and User Data Linkages is that XAttributes can be accessed independently of one another and independent of the element data. There is no absolute maximum size for an individual XAttribute, nor is there a limit on the number of XAttributes per element.
The programming tools for XAttributes are provided by the MicroStationAPI C++ interface. There is no MDL API for XAttributes.
Here's a Be Communities article about XAttributes for developers: Getting Started With XAttributes.
XData was added to MicroStation to improve compatibility with AutoCAD™. MicroStation provides XData Dictionaries as well as being able to store and retrieve XData that is part of an element.
FlexiTable™ uses tags as a data source to create a schedule table that is displayed in MicroStation. However, it's a little more versatile than just a tag editor, because those data can be derived from many different data sources. FlexiTable also exports data in a number of ways.
Tag Elements are available through MicroStation's Tags toolbox. They are graphic objects that may be manipulated and printed like any other element. What's different is that there are built-in tools to query and report on tag data.
Tag Elements contain your data that are associated with
a host element. They are part of the DGN file and require no
external database or application. MicroStation's tag functionality includes
a reporting mechanism. You can save the data from tagged elements
to a CSV or XML file.
MicroStation lets you define a named Tag Set that contains a number of Tag definitions. This is analogous to defining the columns of a table in a database schema.
Some applications created by LA Solutions use Tag Elements to store data. For example, AssetPlanner™ records room areas in tags, includes HTML reports. Its strength is that it automatically updates its area tag value as you edit a room's boundary.
XML Fragments are implemented with technology introduced with MicroStation V8.1. An XML Fragment contains data embedded in an XML element. The XML element and its contained data are attached to a MicroStation graphic element as a data linkage.
Currently there are no user tools available for XML Fragments. The first Bentley Systems application to use XML Fragments was MicroStation GeoGraphics 2004 Edition, which provides GIS analysis, labelling, and reporting using XFM technology. XFM technology continues with Bentley Map™ for MicroStation XM and later.
There is an XML Fragment API for MDL but not for MicroStation VBA. The MDL API provides full access not only to XML Fragments, but also to stand-alone XML data that is part of the DGN file but not associated with any particular graphic element.