[c# COM CONNECT] save settings for file opened with OpenDesignFileForProgram

first this is a stand alone app so I have to use COM.

Maybe im missing something or misunderstanding this but I don't see how to do a save settings on a file that I opened via OpenDesignFileForProgram. I only found the key in but that wont work since its not the active file.

I see the save and saveas methods but I don't see a save settings. I see save settings at the application level. which only affects the active file. isn't save settings saving the design file settings. confused as to why its at the application level and not a method for the file.

Granted most of the things save settings does is GUI related so I see how opendesignfileforprogram wouldn't be the logical to use with save settings. but one of the things save settings does is associate the dgn file with the workspace/workset. which is what im trying to accomplish. since there is no COM call

im trying to get around the fact that DgnWorkSetInfo is not available in COM. and it just takes soo much longer to load the file to the screen (make active).  

  • I don't see how to do a save settings on a file that I opened via OpenDesignFileForProgram

    Why do you feel the need to use that method rather than OpenDesignFileSee this blog.

     
    Regards, Jon Summers
    LA Solutions

  • to save on loading times because I need to do this on multiple files. and really I don't want to see the application at all but there is a bug with -automation when I start microstation, so I have no way to silently open microstation.

    i can just use opendesignfile, just trying to optimize where i can.   

  • it just takes soo much longer to load the file ...

    Software that's correct but slow is preferable to software that is fast but wrong. Develop your app using OpenDesignFile, and when it's working you can explore ways to make the performance acceptable.

    Init Apps

    The idiomatic way to process multiple DGN files without showing graphics is to write an app that can be started as an MS_INITAPP.  I don't know if .NET can do that, but C++ certainly can;  VBA can't.  The app can seize control of MicroStation and prevent it from opening any graphics (unless your code explicitly tells it to).  It also has the benefit of speed: if performance is really an issue for you, then you won't get faster than a native-code app written in C++.

     
    Regards, Jon Summers
    LA Solutions

  • okay im not familiar with MS_INITAPP. ill have to look into it some more and how to create one. really the microstation specific stuff Is just this save settings. so it shouldn't be too much

    im guessing I could start the microstation process and pass the -wa parameter to load this app from my stand alone app. 

    so my stand alone app would do its thing then call up the microstaion process to finish off the work on the dgn files?

  • Hi John,

    a few more notes in addition to Jon's answers:

    Maybe im missing something or misunderstanding this but I don't see how to do a save settings on a file that I opened via OpenDesignFileForProgram.

    There is no reason why there should be "save setting" feature available for OpenDesignFileForProgram method. These two "open methods" target different purposes and offer different set of features.

    Whereas normal open design file is backed by fully active MicroStation, open design file for program is more like "element stream" with only basic (typically elements related) functionality available. More complex concepts like rasters, references, views etc. do not exist in this approach.

    im trying to get around the fact that DgnWorkSetInfo is not available in COM

    Well, VBA / Interop API is pretty limited and is often the last updated in a chain C++ > NET > COM when a new feature is added to MicroStation.

    ill have to look into it some more and how to create one

    I agree with Jon that this is the way to go. I know about a few projects that quite quickly turned from limited Interop API to specifically designed initapp code that works as server communicating (e.g. using some RPC method) with client. An advantage is that in initapps, complete MicroStation API is available.

    I do not see it in CE examples, but there are V8i examples how to implement initapp in native code (which is the best way). I recommend to search also existing discussions, because how to use NET API was discussed also (e.g. here).

    With regards,

      Jan

    Answer Verified By: John Drsek 

  • thanks Jan, so if im understanding this right, its just an addin your loading on start up with the -wa parameter? 

    i was thinking it was some special kind of app. 

  • its just an addin your loading on start up with the -wa parameter? 

    i was thinking it was some special kind of app

    It is a special kind of app.  When you load something with the -wa switch, it is started before MicroStation's UI is initialised, and before any DGN file is opened.  The app must recognise its privileged status and act accordingly...

    • It can proceed to open DGN or other files and process them without showing any UI
    • It can choose to show MicroStation's UI
    • It can choose to show its own UI
    • It can choose to let MicroStation proceed normally, after doing whatever it needs to do

    AFAIK the only option for creating an MS_INITAPP for MicroStation CONNECT is to write a C++ app.  As I commented above, VBA can't do that.  I don't know whether a .NET AddIn can do it: I don't see any evidence that it can, but I'll be pleased to be shown otherwise.  A C++ app. can do it (I've written C++ several apps that are init apps).

     
    Regards, Jon Summers
    LA Solutions

  • Hi,

    It is possible use a C# Addins with MS_INITAPP

     protected override int Run( string[ ] commandLine )
     {
      if( commandLine.Contains( "MS_INITAPPS" ) )
      {
        // start a visible or invisble session
      }
     }

    In order to start a invisible Microstation, you have to open a designfile and then call mdlSystem_entergraphics via pinvoke if you want to use 'view' functionality.

     Utilities.ComApp.OpenDesignFile( dgnFilename, false, MsdV7Action.UpgradeToV8 );
     Utilities.ComApp.Visible = true;
     mdlSystem_enterGraphics( );

    To start a 'visible' Microstation, change the order of the methods above 

          Utilities.ComApp.Visible = true;
          mdlSystem_enterGraphics( );
          Utilities.ComApp.OpenDesignFile( dgn, false, MsdV7Action.UpgradeToV8 );
          
          .
          .
          .
        [DllImport( "ustation.dll", EntryPoint = "mdlSystem_enterGraphics", CallingConvention = CallingConvention.Cdecl )]
        public static extern int mdlSystem_enterGraphics( );

    Regards,

    Harmen

  • thanks Harmen,

    so i think im close. is there a way to not have the app be in the Mdlapps folder? is there a variable that controls this? im using the -WA parameter to kick it off. 

  • is there a way to not have the app be in the Mdlapps folder?

    MicroStation looks for apps in the folders listed in configuration variable MS_MDLAPPS.

     
    Regards, Jon Summers
    LA Solutions