Hi,
I get a very minimal c# initapp working well.
But .. I don't know how to open Microstation MainForm or to avoid Microstation exiting at the end of mi initapp....
Where can i find examples or documentation?
BTW, is there C# Microstation developing tutorials or articles?
Thanks to everybody,
Marco
My simple initapps follows:
namespace UstnInitApp
{
[Bentley.MicroStation.AddInAttribute( ApplicationType = MdlApplicationType.InitApp,
KeyinTree = "Commands.xml",
MdlTaskID = "UstnInitApp")]
public sealed class UstnInitApp : Bentley.MicroStation.AddIn
static UstnInitApp m_App = null;
private UstnInitApp(System.IntPtr mdlDesc)
: base(mdlDesc) {
m_App = this;
}
protected override int Run(System.String[] commandLine) {
MessageBox.Show("Hello from inside Microstation", "Debug", MessageBoxButtons.OK, MessageBoxIcon.Information);
return 0;
Unknown said:I don't know how to open Microstation MainForm or to avoid Microstation exiting at the end of mi initapp
You need to open a DGN file. When used as an MS_INITAPPS, MicroStation remains active only as long as a DGN file is open. Typically, you would process a list of files, and close the last one, at which point MicroStation exits.
Use mdlSystem_enterGraphics if you want to display any graphics (DGN or dialog boxes) to the user.
Regards, Jon Summers LA Solutions
Thanks Jon,
I got it (at last) as shown in the following code:
ApplicationObjectConnector app = new ApplicationObjectConnectorClass();
app.Application.Visible = true;
DesignFile dgn = app.Application.OpenDesignFile( @"C:\example.dgn",true,MsdV7Action.AskUser);
Uhm,
there's a problem inside my example .... it starts two Microstation processes.
I shouldn't use ApplicationObjectConnectorClass and interop!
Any idea on how to open a Microstation MainForm without using interop ?
Thanks,
An AddIn should be built as a DLL, implying that MicroStation must be running in order to load the AddIn. That is, its code executes in MicroStation's address space.
The following statement starts another instance of MicroStation …
But you know already that MicroStation is running.
Attached is a quick example C# class that will allow you to run as an init app. You will have to handle the close part but this will get you started. To run the application it is ustation -wainitaddin where the initaddin.dll is in the mdlapps directory.
HTH,
marka
mark anderson [Bentley]
Visit me at https://communities.bentley.com/communities/other_communities/bentley_innovation/default.aspx
Thank you for your example.
It was quite usefull.
I surprised the only way is using mdlSystem_enterGraphics() ...
marco