The MicroStation Development Library (MDL) and MicroStationAPI provide APIs for developers wanting to create custom applications for MicroStation® from Bentley Systems. We create a MicroStation application as a DLL, written using C++ and built with the Microsoft C++ compiler and linker provided with Visual Studio.
When editing your source code, you can choose whether to use Microsoft Visual Studio, Microsoft Visual Studio Code, or one of your favourite text editors.
When building your app, you can use Visual Studio or the Bentley Systems make (bmake) tools.
A MicroStation DGN model may have other models attached as references. References may be directly attached to the active model. References may be attached to other references, making a nested structure.
In the topics that follow, I'll show some MicroStationAPI collections and the MDL function family each replaces.
Object | Description | Example |
---|---|---|
Reachable ModelRef Collection | A list of references attached to a model | Reachable ModelRef Collection Example |
#include <DgnPlatform/DgnModelRef.h>
#include <DgnPlatform/DgnFileIO/DgnModelRefCollections.h>
DgnModelRefR model = *ISessionMgr::GetActiveDgnModelP ();
ReachableModelRefCollection refs = model.GetReachableModelRefs ();
for (DgnModelRefP modelRef: refs)
{
DgnFileP pFile = modelRef->GetDgnFileP ();
DgnModelP pModel = modelRef->GetDgnModelP ();
if (pFile && pModel)
{
if (modelRef->IsDgnAttachment ())
{
// do something with modelRef
}
}
}
There are two parts to iterating reference attachments: first, enumerate the collection and, second, get information about each attachment.
The mdlModelRefIterator_api
is a typical C-style function family.
The coder — that's you, dear reader — is responsible for memory-management.
When you find an attachment DgnModelRefP
, use the mdlRefFile_api
to get/set
information about that attachment.
DgnModelRefP rootModel = mdlModelRef_getActive (); ModelRefIteratorP iterator; int iteratorTypes = MRITERATE_PrimaryChildRefs | MRITERATE_ExtendedChildRefs; enum Depth { RootAndPrimaryAttachments = 0, RootAndAllAttachments = -1, }; mdlModelRefIterator_create (&iterator, rootModel, iteratorTypes, RootAndAllAttachments); while (DgnModelRefP modelRef = mdlModelRefIterator_getNext (iterator)) { // do something with modelRef DgnAttachmentP info = mdlRefFile_getInfo (modelRef); } // don't forget to deallocate memory mdlModelRefIterator_free (&iterator);
Back to the Iterator main page.
Post questions about MicroStation programming to the MicroStation Programming Forum.