Looking to contribute to this community? Please sign in
Not a member? Register
Problems signing in? Check here
In MicroStation V8, Microsoft's Visual Basic for Applications (or VBA) was introduced. Although there are some similarities in concepts between MicroStation BASIC and VBA, Bentley HIGHLY recommends using VBA and not MicroStation BASIC in any MicroStation V8 version.
While the ultimate decision between the MDL and MicroStation BASIC programming environments will depend on the specific situation, what follows are some general "rules of thumb" to assist MicroStation application developers and users in determining which development tool is appropriate for a given job. Generally speaking, MDL is better suited for professional application development, whereas MicroStation BASIC caters more to user customizations. Given that there are "gray areas" that might be satisfied by either solution and there currently is (and will continue to be) some overlap between MicroStation BASIC and MDL, MicroStation BASIC is not going to "replace" MDL as the recommended tool to use to develop professional level applications.
You can compare the two environments in three contexts:
MDL stands for MicroStation Development Libraries. It is a misnomer, really, as MDL is much more than just a language (the actual "language" used by MDL developers is C). The term MDL encompasses the compilers, linkers and API library used by MicroStation developers. The real "power" of MDL comes from the API library, an extensive array of thousands of built-in functions. A built-in function is just an internal MicroStation routine exposed to third-party application developers. In fact, the MDL built-ins are many of the same functions used by Bentley developers to implement much of MicroStation's functionality. Thus, an MDL programmer can control MicroStation at a very low level by using these same built-in functions.
Almost all MicroStation functionality is packaged up as a series of one or more commands. MDL application developers program directly against MicroStation as a first step. After they have written their application-specific functions, they must then package them in the form of commands. (The MDL Programmer's Guide has a section devoted to the creation of command tables and associating commands with functions.) The main benefit of commands is that they allow a third-party MDL program to "fit in" and function seamlessly with the overall command processing state machine of MicroStation. The commands defined by MDL programmers are actually a valuable resource to MicroStation BASIC programmers. In fact, commands could almost be viewed as "built-in" functions by MicroStation BASIC programmers. All commands, be they defined by core MicroStation or third-party application developers, can be initiated and controlled from a MicroStation BASIC program.
Many of the built-in MDL functions are devoted to the creation and manipulation of objects in a design file. The element descriptor functions in MDL, and the hundreds (if not thousands) of other functions that work with them, allow the MDL application developer to affect the contents of design (DGN) files at a very low level.
Conversely, most of MicroStation BASIC's DGN object processing intelligence is packaged into a handful of objects (that is, MbeElement, MbeDgnInfo) with many methods (routines) being added on a regular basis. Furthermore, these MicroStation BASIC extensions are designed for interpreting and manipulating existing objects, not so much for generating new ones. In fact, there is no intrinsic MicroStation BASIC function or method for creating new objects. Instead, the MicroStation BASIC programmer must find an existing MicroStation or third-party application command that generates the desired objects and then "drive" that command from MicroStation BASIC. The MbeSendCommand MicroStation BASIC extension is used to launch a command. For example, this line of MicroStation BASIC code:
MbeSendCommand "PLACE LINE"
launches the internal MicroStation command to place a line. After starting the command, the MicroStation BASIC macro can then begin sequencing datapoints to the command, defining the end points of one or more line segments. For example:
‘ Coordinates are in master unitsstartPoint.x = 496.386626#startPoint.y = 504.899972#startPoint.z = 2614.709421#‘ Send a data point to the current commandMbeSendDataPoint startPoint, 1%
Because you can drive MicroStation commands from a MicroStation BASIC program, you can create a variety of time-saving utilities. In the example above, a very complex series of line segments can be produced programmatically with little or no user input, whereas creating the same result manually might take many minutes of painstaking precision input.
The same effect can be achieved by using MDL, but many users don't have the C programming background necessary to do that. The learning curve represented by mastering the MDL development environment (learning C, mastering the compiler, linker, make files, command tables, dialog box definitions, etc.) can certainly be intimidating. In fact, one of the driving forces behind MicroStation BASIC was the often-heard request for a simpler way to implement quick and easy programs to allow simple modifications to designs.
When you look at differences in GUI capability between MDL and MicroStation BASIC, you see a model for their general differences. That is, MicroStation BASIC provides the means for doing most things simply, but MDL may be required to create something more complex.
MicroStation BASIC offers a number of extensions to the BASIC language for standard dialog formations and input collection. Some of these extensions include MbeMessageBox, MbeInputBox and MbeSelectBox. For the non-standard job, it is also possible to create custom dialogs in MicroStation BASIC. Keep in mind that with all dialog boxes displayed from MicroStation BASIC, there are limitations-all dialogs displayed in MicroStation BASIC are modal (they must be displayed, manipulated and dismissed before any other processing in MicroStation can take place) and only a subset of all dialog items are supported in MicroStation BASIC.
In MDL, on the other hand, you can create modal and modeless dialog boxes with fairly complex behavior. To see an example of "complex behavior" in a dialog box, run MicroStation and bring up the Modify Color dialog (invoke the Settings>ColorTable menu item, then double-click on any color). Click and drag around in the brightly colored "rainbow box." Note how the other items dynamically change to conform to the mouse movements. That shows the use of both generic items and asynchronous processing that would be impossible to emulate in a MicroStation BASIC custom dialog box.
Differences between MDL and MicroStation BASIC applications can be seen in terms of their respective overall complexity. Writing and maintaining applications gets more difficult as an application gets larger. For example, disciplined programmers (C, BASIC or otherwise) will break up their code into small, reusable subroutines. That is about all you can do to manage complexity in BASIC. In MDL, an application can be further compartmentalized into header files, modules, libraries, shared libraries, DLMs, etc. All of this is necessary to successfully manage applications that reach a certain level of complexity. These subdivisions further necessitate the use of a make program (BMAKE) and make files to manage the relationships between all of the pieces. (And, for someone who doesn't program for a living, all this can be very daunting.)
Both MDL and MicroStation BASIC allow for the creation of a binary executable file (which can only be executed from within MicroStation). In the case of MDL, the application file has an .ma extension, and in MicroStation BASIC, a .ba extension. (Note: .ba files are automatically created in MicroStation-no external compilation is necessary, as with MDL.) The .ba file offers one level of flexibility not found in the MDL program; compiled MicroStation BASIC programs are binary portable to all MicroStation platforms.
When choosing between MDL and MicroStation BASIC to implement a utility or application in MicroStation, keep in mind:
For most users (not programmers) who just want to achieve some modest level of customization of MicroStation, MicroStation BASIC is the place to start. On the other end of the spectrum is the professional software developer with an application in mind, rich in functionality and intended for a broad audience of users. In this scenario, MDL will typically be the environment of choice.
Product TechNotes and FAQs
MicroStation Desktop TechNotes and FAQs
Bentley Technical Support KnowledgeBase
Bentley LEARN Server
Bentley's Technical Support Group requests that you please confine any comments you have on this Wiki entry to this "Comments or Corrections?" section. THANK YOU!