Questions similar to these appear in the Be Communities MicroStation Programming Forum.
Q How do I label a contour with its height?
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.
Here's a set of contours created in a MicroStation DGN model using the built-in tools. The contours are a mix of lines, line-strings and shape elements …
Here's the same set of contours after labelling a couple 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 …
LineElement
, LineStringElement
or ShapeElement
)
TextElement
TextElement
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 LineElement
, LineStringElement
or ShapeElement
.
The label is created at the mid-point of the LineElement
or nearest segment of a LineStringElement
or ShapeElement
.
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.
This tool creates a text element and snaps it to the chosen contour. What you see depends on the text style. If you want to obscure the contour line beneath the text, then choose a text style having an opaque background.
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.
Download the
Label Contours ZIP archive, and unpack it to a suitable location such as
\Workspace\Standards\macros
.
Start the macro using the key-in …
vba run [LabelContours]modMain.Main
Post questions about MicroStation programming to the MicroStation Programming Forum.