[MSCE 10.16 C#] How to get actual config variable value instead of expanded value

MicroStation sets the default value of the MS_REPORT_OUTPUT variable to $(_DGNDIR).

When I use the following code to read the variable: string ReportLocation = ConfigurationManager.GetVariable("MS_REPORT_OUTPUT");

I get the actual disk location of the active file, is there a way to get the non-expanded value? I'm writing an addin for reporting and I have to use keyins to kick off the report and I want to set the location by changing the variable then setting it back to the original before I exit the addin.

Below is quick code test:

 string ReportLocation = ConfigurationManager.GetVariable("MS_REPORT_OUTPUT"); //returns expanded value (the physical file location), not the value of the variable
 ConfigurationManager.DefineVariable("MS_REPORT_OUTPUT", @"C:\temp");            //set location I want the report generated (just a test location for now)
 Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp.CadInputQueue.SendCommand(@"reports export ""Untitled\piertest"""); //run report
 ConfigurationManager.DefineVariable("MS_REPORT_OUTPUT", ReportLocation);  //reset the variable back to it initial non-expanded value

Parents
  • Hi ,

    As explained here GetVariable takes a simplified path forward in MicroStation CONNECT to help eliminate: improper use, dormant memory allocations and confusion when calling: mdlSystem_getCfgVar() vs the more often needed call to: mdlSystem_expandCfgVar(). If there is a need to obtain the unexpanded variable value then it is recommended to import and call msMacro_expandMacroExpression() located in mdlbltin.lib passing false as the last parameter value.

    When providing a forward declaration using the SDK types, it should appear as:

    MSCORE_EXPORT StatusInt     msMacro_expandMacroExpression(WStringR expansion, WCharCP expression, bool immediate, bool fmtExpansion)

    When providing a forward declaration using Microsoft types, it should appear as:

    int __cdecl msMacro_expandMacroExpression(struct Bentley::WString & __ptr64,wchar_t const * __ptr64,bool,bool)

    HTH,
    Bob 



  • Robert,

    Any chance you could point me in the right direction, do I import a lib file using the DllImport attribute like I would for accessing the ustation.dll file?

    I can't find documentation on msMacro_expandMacroExpression method in the MicroStation API Documentation (doing a search on just msMacro shows no hits in the documentation)

Reply Children