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 font search & replace tool for MicroStation, written in MicroStation VBA.
You can search for text in several different element types, and replace the font 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.
The following subroutine uses the Microsoft VBScript Regular Expressions 5.5 to search a string for a Unicode sequence …
This tool searches for text in MicroStation
TextElements
, TextNodeElements
, TagElements
and CellElements
.
For each TextElement
it finds, it tests its font name against the user-supplied font 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 font name to the user-supplied font 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 font search tool is sensitive to user-defined selections and fences. The algorithm implemented here is …
If you want to replace text font, 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 font name matches the user specification, it also replaces the font name 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 Font Replacer MVBA project.
The ZIP package includes the MVBA project TextFontReplacer.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 [TextFontReplacer]modMain.Main
Post questions about MicroStation programming to the MicroStation Programming Forum.