Q How do I increment a MicroStation text element
or text node element that contains a text like AA?
For example, I have a drawing title containing a revision code like
Revision: AA and
I want to revise that to
A If you just want to use the Text Incrementor macro, jump to the download paragraph. Otherwise, keep on reading.
Q How do I create a sequence of MicroStation text elements or text node elements that start with a number and increment that text for each member of a sequence?
A If you just want to use the Text Incrementor macro to sequence numbers, jump to the download paragraph. Otherwise, keep on reading.
Read the text element, pass its content to an incrementor function, set the content to the result, and rewrite the element …
IncrementTextfunction to the
The Text Incrementor VBA project is a working project that implements a text locator along with the text increment function. It works with simple text elements and with text node elements.
It's sensitive to selection sets and fences. If a fence is active, or a selection set is present, the macro processes the elements in that collection. Otherwise, it provides a pick tool, which prompts you to pick text or text node elements.
When used with a text node element, the Text Incrementor looks only at the last text element in the node. That is, if your text node looks like this …
The incrementor considers only the last line (
DEF) and increments that, like this …
You don't have to be a VBA whizz to use this macro. Follow the instruction to download the macro and invoke the key-in mentioned below.
When sequencing text, the Text Incrementor expects an active selection set or a fence. It extracts the text of the first text element in that set, and uses it as the pattern for subsequent values in the sequence.
Text Incrementor looks at the first text or text node element in the selection or fence.
It uses that as the pattern for subsequent text.
For example, if the first element contains text
Revision AA, then Text Incrementor
calculates the next value of the sequence as
N x increment.
N is the current index in the sequence, and
increment is the increment (or decrement) value.
In this example, the sequences becomes …
Revision AA Revision AB Revision AB ... Revision AZ Revision BA
The text in a sequence may not be what you expect. If elements are in a selection set, the numbers correspond to the position of each text element in that set. You have control over the order in which you select elements. If elements are in a fence, the numbers may appear almost random. The increment corresponds to the file order of text elements found in the fence. You have no control over the order in which the Text Incrementor processes the fence contents.
If you want a tool to increment numeric text, then read this article
IncrementText class does the work of incrementing a single text or text-node element, or multiple text or text-node elements.
It extracts the element's text, calculates the incremented value that it applies to the text, then rewrites the text element.
When creating a sequence of numbers, it finds the first text element in the selection or fence, and uses that as a pattern for the rest of the sequence.
For example, if the first text element in the selection contains
ABC AAA, then the pattern for subsequence text will be …
AAA + index * increment.
If you're a VBA developer, then download the macro and examine the source code using MicroStation's Interactive Development Environment (IDE).
IncrementAlpha ZIP archive, and unpack it to a suitable location such as
Start the macro using the key-in …
vba run [AlphaIncrementor]modMain.Main
Or, if you want to sequence values, do this …
vba run [TextIncrementor]modMain.Main sequence
Any of those key-ins reveals the macro version number in MicroStation's Message Center …
Post questions about MicroStation programming to the MicroStation Programming Forum.