Questions similar to these appear in the Be Communities MicroStation Programming Forum.
Q How do I label a line with its length?
Q How do I label a shape with its area and perimeter?
A This article describes a MicroStation VBA project that …
Note that a label created using this VBA tool is static. The label doesn't update automatically if you modify a line or shape — the label stays the same. To update a label that was created using this tool, you must delete the label then run the tool again.
If you want to create a label that updates automatically when a line or shape is modified, then use a Text Field. Unfortunately, VBA doesn't support (as of Update 17.1) text fields. Alternatively, use one of our TagWorks products. AreaAnnotator™ lets you annotate area objects with labels that update automatically if you modify the shape.
In contrast, the Low Cost Labeller mentioned below creates a label that updates dynamically.
Here's a line-string element created in a MicroStation DGN model using the built-in tools …
Here's the same line-string element after labelling with the VBA macro described here …
Here's a shape element after labelling with the VBA macro described here …
Decide how you want to align the label relative to the element or view. Choose an option from the Rotation ComboBox …
The tool works interactively like this …
When a MicroStation selection set or fence is active the macro works in batch mode.
It obtains an
ElementEnumerator from the selection set or fence,
then works through that collection, labelling each
The label is created at the mid-point of the
LineElement or nearest segment of a
When working in batch mode, there is no opportunity for the operator to place the label manually. The Snap Label to Line check box is checked but disabled.
MicroStation enthusiast Massimo Callegher wrote a MicroStation BASIC macro many years ago. MicroStation CONNECT does not include BASIC, so I seized the opportunity to write the VBA macro described here.
This 21st-century macro was written in response to a question in the Be Communities MicroStation Forum. It is supplied as freeware: you can use the macro for your own purposes whether private or commercial. LA Solutions offers the project as-is without any warranty of fitness for purpose. It should work with both MicroStation CONNECT and MicroStation V8i.
MicroStation Reports let you harvest DGN data. For example, you can report line lengths — here's step-by-step guide to creating a Linear Report. You can export a Report to a CSV file, which you can open with Microsoft Excel …
A Text Field
can display DGN element and other properties.
The advantage of a Text Field over plain text is that a Text Field updates automatically
when its related element is changed.
In contrast, a label created using a plain old
TextElement, such as those created by this Label Line tool, does not update automatically.
The Low Cost Labeller is an application for MicroStation CONNECT. It provides a tool to label a line with its length. Low Cost Labeller goes beyond the capabilities of the VBA project described here. While this VBA project creates a static text label, Low Cost Labeller creates a label that includes a Text Field that displays the line's Length property. When you modify the line, the label updates automatically.
Low Cost Labeller is freeware!
Label Lines ZIP archive, and unpack it to a suitable location such as
Start the macro using the key-in …
vba run [LabelLines]modMain.Main
Post questions about MicroStation programming to the MicroStation Programming Forum.