MicroStation is a 3D CAD tool. Users draw 3D or 2D objects in one of eight views. Drawn objects are termed elements. A graphic element represents something that a user can draw, such as a line, arc, rectangle or cone. Elements are persisted to a DGN file: when a user has drawn an object, she can be confident that after finishing a MicroStation session she can subsequently reopen that DGN file to see the previously-drawn elements.
Developers who write applications for MicroStation one of several APIs …
There are times when a developer would like to show a user temporary graphics. For example, during a custom command while constructing a complex object, or an object that relies on adjacent geometry. It is useful to see construction lines that provide clues. Once the command is finished, the temporary graphics vanish: that is, they are never committed to file. Often, the temporary graphics are snappable, meaning that a user can snap a point, such as the beginning of a real line, to the temporary graphics.
An application designer may choose to use some or all the above techniques when specifying how a MicroStation application should work.
Bentley staffer Brien Bastings provided this tip:A view decorator is good for things that may be changing every frame/cursor motion, an IViewTransient is good for things that don't change often.
In MicroStation terminology, such temporary graphics are called transient. Using the MicroStationAPI in MicroStation CONNECT, you can create both transient elements and transient geometry.
The difference between transient elements and transient geometry is that a programmer can convert a normal element to a transient, whereas transient geometry is anything that you can define geometrically. Using the MicroStationAPI to draw transient geometry also gives you finer control over what is drawn during a number of view update events, and whether the geometry is snappable or not.
We wrote this solution in response to a question posed on the Be Community Forums. MicroStation lets programmers create transient geometry in one or more views. Transient geometry and transient elements are never written to file. They may be useful in providing a view of constructions for various reasons — for example, to show a user how a possible contruction may appear before committing it to a model permanentley.
Q How do I draw transient geometry in a MicroStation view?
A A simple question, which turns out to have a complex answer. The MicroStationAPI for MicroStation CONNECT provides the ability to draw pure geometry to a view, as well as the ability to create transient DGN elements.
Let's clarify some terminology. We need to distinguish between persistent and transient elements, between MicroStation elements and pure geometry, and between dynamic and other graphic display events.
With MicroStation CONNECT you can create transient geometry, as opposed to transient elements.
If they are not persistent elements, MicroStation doesn't know about them,
and you are responsible for drawing them.
IViewTransients interface provides us with numerous events when we can draw stuff.
During a dynamic update, the user is moving the cursor and, yes, your function will be called again and again to create
and draw your geometry (geometry, not elements) based on the current cursor position.
Because your geometry is drawn repeatedly, the callback provides an opportunity for you to stop drawing (
during one of those events.
From the user perspective, this lets your application be responsive rather than slowing everying down
because it insists on drawing everything even when there is no need.
If your geometry is static, and does not need to be recalculated relative to the current cursor position, then drawing it repeatedly during dynamics may be unnecessary.
Transient elements are not persistent (they are never written to file). However, they are created from a MicroStation element and stored in the transient cache. MicroStation knows about the transient cache and draws its contents for you.
The purpose of the ViewTransients project is to illustrate the use of the MicroStationAPI and
It requires C++, as does any project that uses the MicroStationAPI.
You register at run-time an instance of a class that inherits from
Subsequently, MicroStation calls your object when certain events happen.
Your code receives an
IViewContext* that you can use to react to different events
and draw geometry in one or more views.
By reacting differently to different events, you can simply draw geometry in a view, or make it snappable for pick user operations. For example, you can make a transient line snappable so that a user can snap to a keypoint on the transient while creating genuine MicroStation elements.
Because you draw pure geometry, you don't need to create elements, and you don't have to use the mdlTransient_API.
We assume that you are using the MicroStation development environment to build this project. Consult the MicroStation Software Development Kit (SDK) help for more information, or take a look at our guide to setting up Windows to build MicroStation applications.
As this is a C++ project, you'll need Visual Studio installed. The project builds from a Bentley make (bmake) file, so the purpose of Visual Studio is to provide a compiler and linker rather than an IDE.
As with any application built for native code, the result is in two parts:
ViewTransients.ma contains only resource data: in this case, the information MicroStation requires to load the DLL,
and a command table.
ViewTransients.dll is the implementation file.
When a user types
mdl load ViewTransients. MicroStation first loads
and finds the resource directive (the
ViewTransients.r) that instructs it to load a DLL,
then it loads
Download the ViewTransients project.
This ZIP file contains C++ source code header and implementation files, and a bmake (
.mke) file to build the project.
Visual Studio 2015 to be installed in order to compile this project
for MicroStation CONNECT.