Introduction

The MicroStation Development Library (MDL) and MicroStationAPI provide APIs for developers wanting to create custom applications for MicroStation® from Bentley Systems. We create a MicroStation application as a DLL, written using C++ and built with the Microsoft C++ compiler and linker provided with Visual Studio.

When editing your source code, you can choose whether to use Microsoft Visual Studio, Microsoft Visual Studio Code, or one of your favourite text editors.

When building your app, you can use Visual Studio or the Bentley Systems make (bmake) tools.

MicroStation Element Properties

MicroStation is a 3D CAD tool. Users draw 3D or 2D objects in one of eight views. Drawn objects are termed elements. A graphic element represents something that a user can draw, such as a line, arc, rectangle or cone. Elements are persisted in a DGN model, which is part of a DGN file.

Developers who write applications for MicroStation one of several APIs …

This article is for developers who use the C++ MicroStationAPI.

SymbologyReporter

A DGN element, as you probably know, has a set of properties. Those include generic properties, such as colour and level, that may belong to any graphic element. They additionally include properties that apply only to certain types of element. For example, a text element has a font property, a cell has a cell name property.

The MicroStationAPI provides the SymbologyReporter class to obtain DGN properties from an element. This is a 21st-century version of the MDL function mdlElement_getSymbology() and similar.

Construct a SymbologyReporter instance by passing it an ElementHandle …

void ReportDgnInformation (ElementHandleCR eh)
{
  SymbologyReporter reporter (eh);
  ...
}

Now you can obtain information about that element …

UInt index = 0;
UInt32 weight = 0;
StatusInt status = reporter.GetWeight (weight, index);

Complex Elements

A complex DGN element has a top-level header and one or more component elements. SymbologyReporter lets you get the properties of those child elements. Pass an index to the property getter to get the symbology of a child element …

UInt index = 7;
UInt32 weight = 0;
// Get weight of the 7th element
StatusInt status = reporter.GetWeight (weight, index);

To iterate all children of a complex element, use a getter in a loop that increments the index and tests the status returned …

UInt32 weight = 0;
StatusInt status = SUCCESS;
while (SUCCESS == status)
{
  status = reporter.GetWeight (weight, index);
  ++index;
}

Questions

Post questions about C++ and the MicroStationAPI to the MicroStation Programming Forum.