Introduction

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

Q How can I merge two text elements 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 stitcher tool. It works with either text elements or text node elements.

VBA Text Stitcher

Join Text Elements

The tool prompts the MicroStation operator to identify a text element, then another text element to be merged. It creates a new text element having the characteristics of the first text picked, then deletes the two original elements.

In other words, the tool will accept two text elements...

word 1
  word 2

Then create a single text element …

word 1 word 2

Unpack a Text Node Element

The tool prompts the MicroStation operator to identify a text node element.. It creates a new text element having the characteristics of the text node, then deletes the original element. The text element displays the concatenated text previously embedded in the text node.

In other words, the tool will accept a text node element …

node line 1
  node line 2

Then create a single text element...

node line 1 node line 2

When you load & run the VBA project it starts a locator class that is tuned to accept only text and text node elements. After picking the first text element, the tool saves that TextElement and prompts the user to pick a second text element.

Once the tool has two TextElements it performs the merge and restarts.

If the first element picked is a text node element, the tool proceeds directly to create a new text element.

TextSplitter Project

A related tool is implemented by the TextSplitter project. The TextSplitter splits a text element at a specified point (usually a space character) and creates two new text elements. Read more on the TextSplitter page.

Download the Text Stitcher VBA Project

Download TextStitcher.ZIP

The above code is available in this MicroStation VBA project. Unpack the ZIP archive and copy TextStitcher.mvba to a location where MicroStation can find it. A good place to copy it would be C:\ProgramData\Bentley\Organization\Standards\Macros. To create a cell legend, type the following into MicroStation's keyin dialog …

vba run [TextStitcher]modMain.Main

Questions

Post questions about MicroStation programming to the MicroStation Programming Forum.