Introduction

MicroStation users sometimes want something different from the set of tools provided in the product.

Q How can I split a text element in MicroStation?

Questions similar to this, posed by MicroStation users and VBA developers, appear on the Bentley Discussion Groups, typically the MicroStation Forum or Programming Forum.

A This VBA project implements a text splitter tool. It works with DGN text elements. It works with both MicroStation CONNECT and MicroStation V8i.

VBA Text Splitter

Split Text Elements

The tool prompts the MicroStation operator to identify a text element. If the selected text contains the separator character (usually a space), it divides the text in two, breaking it at the separator position. It creates two new text elements having the characteristics of the first text picked, then deletes the original element.

In other words, the tool will accept one text element...

Original Text

Then create a two adjoining text elements …

Original Text

They are separate text elements (not a text node), which you can move independently (but read the section about graphic groups) …

Original Text

When you load & run the VBA project it starts a locator class that is tuned to accept only text elements. After picking a text element, the tool saves that TextElement and splits it into two new text elements. It deletes the original text element.

Bulk Changes

TextSplitter is aware of a MicroStation fence or selection set if active. If a fence or selection set is active when you start the tool, it processes all the text elements in that fence or selection set.

Graphic Groups

TextSplitter comprehends MicroStation's graphic groups. TextSplitter creates two text elements. If the original text element has a non-zero graphic group (GG) value, the new text elements inherit that GG. If the original text element does not have a GG value, then the tool gets the next available GG. It assigns that new GG value to both text elements.

The reason for assigning a graphic group (GG) is that some MicroStation tools will treat the two as one unit if the GG lock is on. For example, you can move the two elements as if they were a single element.

Named Groups

For many purposes, the 21st century Named Groups are an improvement on graphic groups. TextSplitter does not comprehend MicroStation named groups.

TextStitcher Project

A related tool is implemented by the TextStitcher project. The TextStitcher joins two or more text elements and creates a new text element. Read more on the TextStitcher page.

Download the Text Splitter VBA Project

Download TextSplitter.ZIP

The above code is available in this MicroStation VBA project. Unpack the ZIP archive and copy TextSplitter.mvba to a location where MicroStation can find it. A good place to copy it would be C:\ProgramData\Bentley\Organization\Standards\Macros.

How to start TextSplitter

To start splitting text, type the following into MicroStation's keyin dialog …

vba run [TextSplitter]modMain.Main

Questions

Post questions about MicroStation programming to the MicroStation Programming Forum.