MicroStation and Application Development

MicroStation® is a computer-aided-design (CAD) tool produced by Bentley Systems. It is used by engineers, architects, and draughting technicians to create 3D models and 2D drawings.

MicroStation can be customised. Bentley Systems themselves have many applications for specialised markets that use MicroStation as a platform. Third-parties likewise may use MicroStation as a platform on which to develop their application software. Bentley Systems provide the MicroStation CONNECT Software Development Kit (SDK) that software developers use to create their applications. The SDK has two libraries …

The MicroStationAPI is the sole API for C++ programmers. Earlier versions of MicroStation provided the MicroStation Development Library (MDL). MDL is not available as a separate API with MicroStation CONNECT, but is subsumed into the MicroStationAPI. This article attempts to clarify and explain the MicroStationAPI from a developer's viewpoint.


ustnTaskId is a public MicroStationAPI variable. It is used in a number of functions, such as mdlInput_sendCommand (). The MicroStationAPI mentions it a few times, but doesn't tell you how to use it.

Declaring ustnTaskId

Before you can use ustnTaskId you must declare it. You won't guess the incantation, so here it is …


BENTLEYDLL_EXPORT extern WCharCP      ustnTaskId;


Glossary of Macros

Those macros are #defined in various MicroStationAPI headers. Look in Bentley\Bentley.h for the full definition. Briefly …

Using ustnTaskId

Once you've declared ustnTaskId as shown above you can use it in your code. For example …

//  Unload the current application
mdlInput_sendCommand  (CMD_MDL_UNLOAD, mdlSystem_getCurrTaskID (),
        INPUTQ_EOQ, ustnTaskId, 0);

Linking ustnTaskId

Finally, you must link your app. with the appropriate MicroStationAPI library. Put this in your bmake file …

LINKER_LIBRARIES        + $(mdlLibs)mdlbltin.lib

Header File

We've wrapped the above in a header file. Copy the code below and save it to something like Declare_ustnTaskId_Import.h. Then include it in your source code whenever you need to use ustnTaskId …

#pragma once

#include <Bentley/Bentley.h>


BENTLEYDLL_EXPORT extern WCharCP      ustnTaskId;




Thanks go to Bentley Developer Network (BDN) support staffer Robert Hook. Bob provided the necessary detail described above.