Let me start with very small a Hello World app using MDL programming. This will give an idea where to start, how to compile and produce a .ma file and run the .ma file. I will try to resist the temptation to add many theoretical details at first. Just want to give that eureka moment for a beginner MDL programmer. With further modules I will try to explain more in detail slowly. You can contact me in case you have any queries, you can put the comments or email me.
I am going to develop the HelloWorld mdl app on Microstation v7 in Windows enviroment. So make sure it is installed fully on your PC.
You are expected to have basic knowledge of C or C++, code debugging and compile error resolutions etc. You will also have to refer MDL Help from the Microstation menu, time to time.
There are a number of source file types involved (.mc, .h, .r etc.). You can write those using Notepad, Notepad++, Visual Studio or any other text editor. In this example we will code HelloWorld.mc file.
After compiling process, it will produce HelloWorld.ma which when executed; Microstation will interpret and show a dialog box.
First, open the console window
This will open a command prompt as:
Create a HelloWorld.mc.
Write the following in HelloWorld.mc and save the file.
#include <mdl.h>
#include <dlogitem.h>
int main()
{
mdlDialog_openInfoBox(“Hello World!!”);
return 0;
}
The first two file are the preprocessing directives. The main function has a call to mdlDialog_openInfoBox function which will open a modal dialog box.
If you open Windows Explore, you will find under the MicroStation directory, there is folder as mdl\include. Note the whole path.
In the command prompt, type the following.
set MDL_COMP=-i<path to mdl include folder>
In my case, it is
set MDL_COMP=-iF:\Bentley\Program\MicroStation\mdl\include
This will help compiler to find where the .h (header files with function definitions) files are. Otherwise, you will get the errors such as Can’t include mdl.h
Now, start the compiling process. Use the MCOMP utility first. This will produce .mo file in the same folder where .mc file is.
Use the MLINK utility and produce the .MA file.
We are there!!
Open Microstation and give the command as
mdl l c:\temp\HelloWorld
It will show a dialog box.
You can refer the next lesson Place a Linestring using MDL where you will learn how a linestring can be placed using MDL, you will also learn about dynamic update in the same lesson.