The MicroStation Development Library (MDL) and MicroStationAPI provide APIs for developers wanting to create custom applications for MicroStation® from Bentley Systems. We create a MicroStation application as a DLL, written using C++ and built with the Microsoft C++ compiler and linker provided with Visual Studio.
When editing your source code, you can choose whether to use Microsoft Visual Studio, Microsoft Visual Studio Code, or one of your favourite text editors.
When building your app, you can use Visual Studio or the Bentley Systems make (bmake) tools.
The MicroStation SDK delivers ..\examples\Annotation\ModifyTextTool
.
That example is idiosyncratic in its operation, and doesn't deliver what one expects.
What ..\examples\Annotation\ModifyTextTool
actually does is to provide
a locate tool that lets you pick a text element.
Once picked, the AddIn copies the text, modifies it, then lets you place the new text in the active DGN model.
The original text element is left unchanged. So the tool doesn't modify anything, but instead creates new text.
The above peculiar behaviour puzzled at least one person who posted a question to the MicroStation Programming Forum. How do we write a tool that lets one pick a text element, then replace its contents in situ?
We wrote an extended version of the SDK example. It adds some commands to replace text, and some tool classes to implement those new commands.
The commands in the ReplaceText example are …
Key-In | Command Class | Comment |
---|---|---|
CHANGETEXT HELP VERSION | Shows the DLL version number | |
CHANGETEXT COPY CASE LOWER | ChangeCaseToolLower | Same as SDK ModifyText example |
CHANGETEXT COPY CASE UPPER | ChangeCaseToolUpper | Same as SDK ModifyText example |
CHANGETEXT COPY TEXT | ChangeTextTool | |
CHANGETEXT REPLACE CASE LOWER | ReplaceCaseLowerTool | Changes original text element |
CHANGETEXT REPLACE CASE UPPER | ReplaceCaseUpperTool | Changes original text element |
CHANGETEXT REPLACE TEXT new text | ReplaceTextTool | Changes original text element |
The commands new to ReplaceText example are those that replace the existing text in a text element.
There's also CHANGETEXT HELP VERSION
, which is described below.
The new tool classes that replace text are simpler than those in ModifyTextExample.
User starts the command, picks a text element, and the element's content is changed and the element updated.
The text content is handled with a TextBlock
, and the example shows how to extract and update the text in
a TextBlock
.
Read this article that show to embed a Windows resource into your MicroStation AddIn.
The above code is available in this C++ project. Unpack the ZIP archive and copy the source code to a suitable location.
Post questions about C++ and the MicroStationAPI to the MicroStation Programming Forum.
Return to MicroStationAPI articles index.