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.
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!.
LikeLike
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
LikeLike
Hi VijaySambe! How are you this Veeresh from CADSYS..,
LikeLike
Hi VijaySambe! how link command to a function in mdl…
LikeLike
Hi Veeresh, how are you doing and hows everyone in CadSys? Let me know what exactly you trying to achieve, I might blog about it. Thanks.
LikeLike
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,
LikeLike
Actually I want create Custom Command and assign specific functionality to it.. If you already blog it. please send the url
LikeLike
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.
LikeLike
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.
LikeLike
Thanks..,
LikeLike
[…] As you see the code above can be saved as a whole (with comments) in a file placeline.mc and compile as explained in the blog – Hello World MDL […]
LikeLike
Vijay Sir, I would like to learn MDL. Could you please help me?
LikeLike
Hi, Can you read the blog I have written to get you started, in future hope to post more.
LikeLike