Questions similar to these appear in the Be Communities MicroStation Programming Forum.
This page lists some solutions to common MicroStation VBA (MVBA) problems. Tips are published as examples and are not necessarily working code.
We've created a
text style search & replace tool for MicroStation, written in MicroStation VBA.
You can search for text in several different element types, and replace the text style of each TextElement
found.
You don't need to know anything about VBA to use our tool. If you're not interested in the description of the VBA code that follows, then skip to the download section.
This tool searches for text in MicroStation
TextElements
, TextNodeElements
, TagElements
and CellElements
.
For each TextElement
it finds, it tests its style name against the user-supplied style name.
Press the Find button. The tool scans the active DGN model for elements that might contain text. For each text element that it locates, it extracts its text and compares its style name to the user-supplied style name. The number of matches is shown next to the Find button.
The tool pops the Search Results dialog that shows the Element IDs and type description of each matching element …
The Search Results dialog shows a list of matching elements.
Select a row in the list and click the Locate button to instruct MicroStation to focus on the selected element in view 1.
Click the Select button to instruct MicroStation to add all elements in the list to a selection set.
This text style search tool is sensitive to user-defined selections and fences. The algorithm implemented here is …
If you want to replace text style, then take these additional steps …
Press the Execute button. The tool scans the active DGN model as before. This time, in addition to finding text whose style name matches the user specification, it also replaces the style for each match.
This operation is undoable. The command is stored in MicroStation's command buffer, so you can choose Edit|Undo to reverse the changes …
You can download the Text Style Replacer MVBA project.
The ZIP package includes the MVBA project TextStyleReplacer.mvba
.
If you're interested in the VBA source code, then that's included. Just open the project in MicroStation's VBA Interactive Development Environment (IDE).
..Organization\Standards\macros
vba run [TextStyleReplacer]modMain.Main
Post questions about MicroStation programming to the MicroStation Programming Forum.