Does we have the same level of api access(access Bentley DGN files with full fidelity) when develop extension on top of Microstation with a C# addin and a MDL application.

Hi all, 

  I am new to Microstation development, and recently i want to develop an extension which is to "read" DGN file data(geometry, properties, reference...), i am not familiar with the MDL development environment( especially about the make file, resource file..),  and would like to start with an C# addin, this environment is familiar to me and i can quickly start and focus on my logic.  but i am not sure whether i have the same level access to the APIs, i have read a lot threads, wikis, and seems the MDL application have more api access to the DGN file filed. what i need is just to read the DGN file information(geometry, properties, references..)

can any expert help me confirm whether i can get the same level api access if i start with an C# addin, from the DGN file "read" perspertive, access Bentley DGN files with full fidelity.

and by the way, the DGN file is generated by AECOsim.

thanks,

Rick

.

Parents
  • Hi Rick,

    as Jon wrote, there is not "real NET API" available in MicroStation V8i and Interop is used. So as you wrote already, what is available in C# is equal to VBA API, plus some extra classes (but not documented) to integrate WinForms into standard MicroStation dialog system (e.g. to create own Tool Settings dialog).

    Because it's not C/C++ versus NET, but C/C++ versus VBA and VBA is macro and rapid prototyping tool, not full featured API, so they don't offer the same functionality and when using VBA (directly or the same API through Interop), many limitations exist.

    In CONNECT Edition a new NET API was introduced and it provides access more similar (but not equal) to native C/C++ API. Old Interop is still maintained and part of official NET API.

    I guess it's not defined anywhere, but "API priority and features" are:

    • Native C and C++ API: The primary API, the most featured, fastest and maintained as the main one.
    • NET: "Second level" API, especially in V8i, much better in CONNECT Edition, but even in CE some differences exist (and NET will be always slower in some situations, not because of NET, but because it's build on top of native code, so some overhead exists).
    • VBA: User oriented tool with many limitations.

    Unknown said:
    my question is that whether the VBA API has full access to the DGN file(access Bentley DGN files with full fidelity)

    No, it does not. There are plenty of features (e.g. XAttributes, advanced solid modelling etc.) that are not available in VBA.

    Unknown said:
    o whether the MDL API always has an equivalent VBA API?

    It has not, because it's not the role of VBA API.

    Unknown said:
    if i start with an C# addin, from the DGN file "read" perspertive, access Bentley DGN files with full fidelity

    In my opinion it should be solved in opposite direction: If there is a problem or task that has to be solved, a proper tool tool has to be found and used. If you need tight integration and full access to DGN data, in V8i native code (which means "old C" and "new C++ MicroStationAPI") should be used. Or if you can migrate to CONNECT Edition, NET will offer you much better access, but because it's quite new API, it's not clear whether really everything is available (but it's still 10x better and richer API comapring to Interop).

    Unknown said:
    and by the way, the DGN file is generated by AECOsim.

    All MicroStation APIs provides access to MicroStation data. It does not help you to interpret AECOsim data structures (I guess you mean Building Designer), it's the role of AECOsim BD API. For example (my knowledge of AECOsim BD is limited), using MicroStation C/C++ API you willl receive cell with plenty of element data (I guess XAttrbiutes) in in, but the API will not tell you it's a wall with windows with some parameters. This interpretation is inside AECOsim BD API.

    With regards,

      Jan

    Answer Verified By: Rick cheng 

  • thanks Jan for the clarification, and you reply did answer my question. and i have a follow question regard the api, i found in the sdk document, there is a document named MicrostationAPI which is the api we are talking about, and the other document is named "MDLAPIFunctionReference", i guess those MDLAPI should be equal to MicrostationAPI, is it true?

    and can i write an C++ addin which will reference MicrostationAPI, so i can have more broad api access? is there any sample?

  • Hi Rick,

    Unknown said:
    i guess those MDLAPI should be equal to MicrostationAPI, is it true?

    No, these API are not equal in V8i. The history of API development leads to this confusion (and was solved mostly in CONNECT Edition):

    I hope it will become clear based on this short history overview (ignoring digressions like Java API / JMDL etc.):

    • MicroStation from V4 offered MDL, which was "C like" environment based on Bentley proprietary technology when C code (with a few extensions and exceptions) was compiled into pseudocode ma and resource rsc files (pseudocode was used here years before Java and NET ;-)
    • When MicroStation V8 was release, native application started to play more important role and MDL API was extended to support native C code. Because of that, there are 2 sets of MDL libraries: One for old pseudocode and the second for native Visual C code, but offering the same set of functions called "MDL functions". This API is C based.
    • From lets say V8 2004 Edition pseudocode API is treated as absolete and it has been recommended to use native code only and to migrate the existing pseudocode apps. to native format.
    • In V8i SELECTseries <something>, new C++ API was introduced and named MicroStationAPI. It offered some new features (e.g. primitive / location / ... commands are implemented in very different way), but is does not replace existing MDL C API and it does not offer the same functionality. It's more like extension and because C and C++ can coexist, applications typically use both depending on required functionality.
      In my opinion MicroStationAPI in V8i was something like "learning and evaluation from testing" for Bentley developers, because in CONNECT Edition, unified C++ API was introduced, offering functionality of both C and C++ API from V8i (and much more).

    There are some philosophy differences between MDL C API and MicroStation C++ API (e.g. how elements are identified), but it's still the same memory model, so it's easy to work in C++ API and when necessary, to pass an element (e.g. like pointer to Element Descriptor) to C function.

    Unknown said:
    and can i write an C++ addin which will reference MicrostationAPI, so i can have more broad api access?

    It's not called addin, because it's not NET code derived from Addin class. Usually it's called just "application" or "MicroStation application".

    Because you can use C and C++ APIs at the same time, there is no reason to distinguish between them. In reality it's easier to use C API in V8, because it's better documented and there are more examples. But some features are available in C++ only (and vice versa).

    To create native code application for V8i, you need Visual Studio 2005 Professional. I know some develoeprs use VS2008 instead of VS2005, but you should be aware of potential threats because of different C runtime versions.

    Unknown said:
    is there any sample?

    MicroStation SDK is delivered with some examples. The most of them are MDL C oriented, but I guess some from them use also C++ API.

    With regards,

      Jan

Reply
  • Hi Rick,

    Unknown said:
    i guess those MDLAPI should be equal to MicrostationAPI, is it true?

    No, these API are not equal in V8i. The history of API development leads to this confusion (and was solved mostly in CONNECT Edition):

    I hope it will become clear based on this short history overview (ignoring digressions like Java API / JMDL etc.):

    • MicroStation from V4 offered MDL, which was "C like" environment based on Bentley proprietary technology when C code (with a few extensions and exceptions) was compiled into pseudocode ma and resource rsc files (pseudocode was used here years before Java and NET ;-)
    • When MicroStation V8 was release, native application started to play more important role and MDL API was extended to support native C code. Because of that, there are 2 sets of MDL libraries: One for old pseudocode and the second for native Visual C code, but offering the same set of functions called "MDL functions". This API is C based.
    • From lets say V8 2004 Edition pseudocode API is treated as absolete and it has been recommended to use native code only and to migrate the existing pseudocode apps. to native format.
    • In V8i SELECTseries <something>, new C++ API was introduced and named MicroStationAPI. It offered some new features (e.g. primitive / location / ... commands are implemented in very different way), but is does not replace existing MDL C API and it does not offer the same functionality. It's more like extension and because C and C++ can coexist, applications typically use both depending on required functionality.
      In my opinion MicroStationAPI in V8i was something like "learning and evaluation from testing" for Bentley developers, because in CONNECT Edition, unified C++ API was introduced, offering functionality of both C and C++ API from V8i (and much more).

    There are some philosophy differences between MDL C API and MicroStation C++ API (e.g. how elements are identified), but it's still the same memory model, so it's easy to work in C++ API and when necessary, to pass an element (e.g. like pointer to Element Descriptor) to C function.

    Unknown said:
    and can i write an C++ addin which will reference MicrostationAPI, so i can have more broad api access?

    It's not called addin, because it's not NET code derived from Addin class. Usually it's called just "application" or "MicroStation application".

    Because you can use C and C++ APIs at the same time, there is no reason to distinguish between them. In reality it's easier to use C API in V8, because it's better documented and there are more examples. But some features are available in C++ only (and vice versa).

    To create native code application for V8i, you need Visual Studio 2005 Professional. I know some develoeprs use VS2008 instead of VS2005, but you should be aware of potential threats because of different C runtime versions.

    Unknown said:
    is there any sample?

    MicroStation SDK is delivered with some examples. The most of them are MDL C oriented, but I guess some from them use also C++ API.

    With regards,

      Jan

Children