Determine _ustn variable from outside of uStation without starting/opening uStation?

I would like to build an external .exe program to read some _ustn variables.  Is this possible?  Do I have to open an instance of uStation to accomplish it?  (Ideally I woud NOT need to open an instance of uStation.)  If so, could I get a portion of code to accomplish this?  I don't care what language the external .exe program is written in (C, VB, etc.)

Thanks in advance,

Christmas May

Parents
  • Hi Christmas,

    Unknown said:
    I would like to build an external .exe program to read some _ustn variables. Is this possible? 

    In my opinion there are two solutions:

    • Start MicroStation (e.g. at background using COM) and let MicroStation parse variables. It's preferred in my opinion, simpler and safer.
    • Write own parser of MicroStation configuration files. The files are plain text files only, so it's technically possible, but you have to support all existing features (conditions, macros, levels...) to be able to read the configuration correctly.

    Unknown said:
    If so, could I get a portion of code to accomplish this?

    My assumption is that to implement such parser is not easy task (a few weeks maybe?) to be sure it works fine and you will still use not certified not supported access to MicroStation configuration. If you prefer this option, I guess you have to invest your time (to write own parser) or money (to pay somebody else).

    With regards,

      Jan

  • Is there some specific variable you are looking to identify the value for as a starting point?
    Or can you describe what you would like to achieve by obtaining 1 or more variable values?

    Without knowing the above we may not be able to provide an optimal recommendation.

    Bob



  • I was hoping to write a standalone .exe file to read the _ustn_Localuserappdatapath variable. If I have to actually "kick off" an instance of uStation to accomplish this, then so be it. However, I would rather not.
  • When MicroStation starts up it processes a number of configuration files.  There are multiple levels of configuration, with one configuration file calling one or more other configuration files.  Each configuration file defines a number of configuration variables, one of which is what you are after.

    However, one variable may be defined in terms of another variable.  There are conditional tests that affect how a variable ends up being defined.  Because CAD Administrators can, and do, define their own configuration files, it's impossible to forecast what the eventual set of variables will be once MicroStation is initialised.  Even on the same site, different projects will have different configurations.

    You have two choices...

    1. Write a configuration file parser that exactly matches MicroStation's built-in processor
    2. Write an app. that looks at an existing instance of MicroStation and gets its variables

    Take your pick!  However, for quick initial development, I suggest that you choose no. 2.  For lengthy unsupported development (there's no public information about MicroStation's configuration file processor), choose no. 1.

     
    Regards, Jon Summers
    LA Solutions

  • Hi Christmas,

    Unknown said:
    If I have to actually "kick off" an instance of uStation to accomplish this

    This is not "you have to"! As Jon wrote "Take your pick" ... you have a freedom to choose. Because nobody knows all details and conditions (should it be general or desinged for very fixed in-house installation, your knowledge of MicroStation development versus general development, how a solution maintenance is planned...), only you can do a qualified decision.

    On a general level, it seems all responding people think to use MicroStation to access configuration is less risky and simpler way.

    Unknown said:
    I was hoping to write a standalone .exe file to read the _ustn_Localuserappdatapath variable.

    Create and analyze msdebug.txt file to check how this configuration variable is defined. It will provide you some extra information how complex the task can be.

    From msdebug.txt it's clear _USTN_LOCALUSERTEMPPATH variable (don't write it as _ustn_Localuserappdatapath, by default MicroStation variables are named using capital letters, so other form can be confusing) is predefined variable, so it's not defined in any config file. And it's also not documented where predefined varaibles come from (where they are defined), I guess they are hardcoded or defined as runtime values.

    Unknown said:
    As for the second solution, where are these files located?

    There are spread over more folders, some are standard (config folder), others depend on workspace configuration. The whole system is described in MicroStation documentation.

    Unknown said:
    Are there any code examples to get me started?

    Use MicroStation VBA documentation, there is chapter describing how to access MicroStation from another process using COM Application object.

    With regards,

      Jan

  • _USTN_LOCALUSERAPPDATAPATH is one of MicroStation's predefined/built in runtime macro definitions and should equate to doing this in Windows Explorer:

    %LOCALAPPDATA%\Bentley\MicroStation\

    You can simply query for the subfolder versions (Major.Minor.Subminor directory name) installed and append the version number for the build required.  For example, one of my installs is defined as:

    _USTN_LOCALUSERAPPDATAPATH: predefined     = C:\Users\robert.hook\AppData\Local\Bentley\MicroStation\10.0.0_3\ <Locked>

    And can be opened in Explorer, via ShellExecute, etc. as:

    %LOCALAPPDATA%\Bentley\MicroStation\10.0.0_3

    If you needed to know what version is installed you could query the registry location HKEY_LOCAL_MACHINE\SOFTWARE\Bentley\MicroStation, for respective "Version" keys having a value like: 10.04.00.046 which you could parse and format to match an expected directory location like above.

    HTH,
    Bob



Reply
  • _USTN_LOCALUSERAPPDATAPATH is one of MicroStation's predefined/built in runtime macro definitions and should equate to doing this in Windows Explorer:

    %LOCALAPPDATA%\Bentley\MicroStation\

    You can simply query for the subfolder versions (Major.Minor.Subminor directory name) installed and append the version number for the build required.  For example, one of my installs is defined as:

    _USTN_LOCALUSERAPPDATAPATH: predefined     = C:\Users\robert.hook\AppData\Local\Bentley\MicroStation\10.0.0_3\ <Locked>

    And can be opened in Explorer, via ShellExecute, etc. as:

    %LOCALAPPDATA%\Bentley\MicroStation\10.0.0_3

    If you needed to know what version is installed you could query the registry location HKEY_LOCAL_MACHINE\SOFTWARE\Bentley\MicroStation, for respective "Version" keys having a value like: 10.04.00.046 which you could parse and format to match an expected directory location like above.

    HTH,
    Bob



Children
No Data