Q Is there any way to capture MicroStation® messages like error, prompt, command, status using Python?
A MicroStation's Message Center provides a resizable panel where informational, status and error messages are posted by MicroStation's built-in commands. You can communicate in various way with your program's users. You can also send debug messages that they can copy and send to you to aid with diagnostics.
There are several show message routines that show a message to your user.
There are several types of message: Informational, Error or Warning and Debug.
Each ShowXxxMessage
subroutine has one required argument: a short message. Optionally, you
may provide an additional longer message and a Boolean
value to
pop a modal dialog.
Here's some Python code that illustrates several ways to call ShowMessage
.
Watch out for line-wrap …
MessageCenter.ShowInfoMessage("terse message", 'verbose message', False)
MessageCenter.ShowErrorMessage('Invalid elementID', 'Please enter valid elementID', False )
# For developers
MessageCenter.ShowDebugMessage('For your eyes only', "Users won't see this message", False )
The Message Center has a Debug property that the user can set to show or hide
messages having the msdMessageCenterPriorityDebug
priority. You can set this property by right-clicking
the Message Center and toggling the check-box …
An invaluable feature of the Message Center is that a user can copy your message from the lower pane captioned Message Details.
When you're developing code, make use of this feature. Instruct the user to enable the Debug property,
described above, and insert ShowDebugMessage
calls into
your code. When things go wrong, ask the user to copy the debug
messages and e-mail them to you for easier diagnosis.