Microstation Development Language (MDL) – Hello World

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

1

This will open a command prompt as:

2

Create a HelloWorld.mc.

3

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.

4

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.

6

Use the MLINK utility and produce the .MA file.

7

We are there!!

Open Microstation and give the command as

mdl l c:\temp\HelloWorld

It will show a dialog box.

9

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.

Cheers!!! smley

13 thoughts on “Microstation Development Language (MDL) – Hello World

  1. HI,
    I am a vba developer. I am interest to work with MDL but i don’t know mdl.Ii am follow your instruction for make a hello world program but i get the following error message when compile the program

    “Files.mc: can’t open”
    No such filr or directory

    can you give the solution for solve the problem

    Thanks!.

    Like

  2. Hi Karthik, Which path did you create the Files.mc, You need to either add the path in to the system path or when compiling correctly give the path of the mc and mo file. PM me you personal email we can chat over it, would be glad to start you off onto the MDL journey. Vijay

    Like

  3. Hi VijaySambhe! I am very happy to hear you again, thanks..you remembered me..,
    including me all very good here.., May I have your email id to have touch with you.. mine is veersh@aol.com,

    Like

  4. Actually I want create Custom Command and assign specific functionality to it.. If you already blog it. please send the url

    Like

  5. Hi Vijay Sambhe! Can you please help me in below issue
    I need to re route the already existing linetring feature with new coordinate points.
    I would like overwrite a linestring element feature coordinates. with new coordinates.

    Like

    • Hi Veeresh, I am not in touch with MDL anymore, its just the old knowledge I am sharing. If I remember correctly, you will have to create a new line string with new descriptor and replace the old element descriptor – Please check the function mdlElmdscr_replace in the mdl help. Best Luck. Thanks.

      Like

Leave a comment