Questions similar to this appear on the Bentley Discussion Groups.
MicroStation provides two sorts of text element: text nodes (VBA TextNodeElement
) and text (VBA TextElement
).
A TextElement
is the simpler: it contains a single line of text.
It has no line termination, such as a line-feed or carriage return.
A TextNodeElement
is more complex.
It is, in MicroStation terminology, a ComplexElement
.
In other words, a container that holds one or more TextElement
s.
Using MicroStation's text editor, it's easy to create and place a TextElement
in your DGN model.
It's also easy to create, intentionally or inadvertently, a TextNodeElement
when you type
Enter or Return while editing your text.
Sometimes you don't want a TextNodeElement
with those pesky carriage returns.
Sometimes you just want a plain line of text with no breaks.
The VBA project described here does exactly that: it unravels a TextNodeElement
into a single TextElement
.
The project provides a Text Node Picker class (clsTextNodePicker
).
That's a VBA class that Implements ILocateCommandEvents
, tuned to handle TextNodeElement
s and nothing else.
The interesting work is done by VBA function ConvertTextNode
…
' ---------------------------------------------------------------------
' ConvertTextNode
' Extract the text components from a text node element and create a
' new text element.
' Returns: TextElement
' ---------------------------------------------------------------------
Public Function ConvertTextNode(ByVal oNode As TextNodeElement) As TextElement
Set ConvertTextNode = Nothing
Const SPACE As String = " "
Dim s As String
Dim words As ElementEnumerator
Set words = oNode.GetSubElements
Do While words.MoveNext
s = s + words.Current.AsTextElement.Text
s = s + SPACE
Loop
Set ConvertTextNode = CreateTextElement1(oNode, s, oNode.Origin, oNode.Rotation)
End Function
The function creates a new TextElement
having the same origin and rotation as the TextNodeElement
.
It uses the TextNodeElement
as a template, so should inherit the node's symbology and level settings.
Download a ZIP package
that contains the ConvertTextNodeToText.mvba
project.
..\Orangisation\Standards\macros
folder
vba run [ConvertTextNodeToText]modMain.Main