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
The MicroStationAPI mentions it a few times, but doesn't tell you how to use it.
Before you can use
ustnTaskId you must declare it.
You won't guess the incantation, so here it is …
BEGIN_EXTERN_C BENTLEYDLL_EXPORT extern WCharCP ustnTaskId; END_EXTERN_C
Those macros are
#defined in various MicroStationAPI headers.
Bentley\Bentley.h for the full definition.
END_EXTERN_Cbracket statements that you want to declare
extern "C". They save some typing
BENTLEYDLL_EXPORTis shorthand for
externis standard C++, indicating that a variable is declared externally to the current code module
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);
Finally, you must link your app. with the appropriate MicroStationAPI library. Put this in your bmake file …
LINKER_LIBRARIES + $(mdlLibs)mdlbltin.lib
We've wrapped the above in a header file.
Copy the code below and save it to something like
Then include it in your source code whenever you need to use
#if !defined(DECLARE_USTNTASKID_H_INCLUDED_) #define DECLARE_USTNTASKID_H_INCLUDED_ #pragma once #include <Bentley/Bentley.h> BEGIN_EXTERN_C BENTLEYDLL_EXPORT extern WCharCP ustnTaskId; END_EXTERN_C #endif // !defined(DECLARE_USTNTASKID_H_INCLUDED_)
Thanks go to Bentley Developer Network (BDN) support staffer Robert Hook. Bob provided the necessary detail described above.