[MSCE C#]通过COM技术打开文件怎么选择engine?

我电脑上装了MSCE,OPD等engine。请问怎么指定具体的engine?

Parents
  • 如下代码所示:

    Process p = new Process();
                p.StartInfo.FileName = @"C:\Program Files\Bentley\OpenBuildings CONNECT Edition\OpenBuildingsDesigner\OpenBuildingsDesigner.exe";
                p.StartInfo.Arguments = "-automation";
                p.Start();
    
                Bentley.Interop.MicroStationDGN.Application msApp = null;
                for (; ; )
                {
                    try
                    {
                        //获取到之前启动的MSTN进程对象,这里加了异常处理是因为MSTN进程启动需要相应的时间。在这段时间里获取msApp会发生异常。所以在这里一直执行
                        //直到不发生异常才跳出循环
                        msApp = (Bentley.Interop.MicroStationDGN.Application)Interaction.GetObject(null,
                           "MicroStationDGN.Application");
                        break;
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                if (null == msApp)
                    return;
                msApp.Visible = false;
                string seedFile = @"D:\CETest.DGN";
                msApp.OpenDesignFile(seedFile, false);
                Point3d[] ptArr = new Point3d[2];
                ptArr[0] = msApp.Point3dZero();
                ptArr[1] = msApp.Point3dFromXYZ(10, 0, 0);
                LineElement lineEle = msApp.CreateLineElement1(null, ptArr);
                msApp.ActiveModelReference.AddElement(lineEle);
                MessageBox.Show("Success");
                msApp.Quit();

    Answer Verified By: fan yang 

Reply
  • 如下代码所示:

    Process p = new Process();
                p.StartInfo.FileName = @"C:\Program Files\Bentley\OpenBuildings CONNECT Edition\OpenBuildingsDesigner\OpenBuildingsDesigner.exe";
                p.StartInfo.Arguments = "-automation";
                p.Start();
    
                Bentley.Interop.MicroStationDGN.Application msApp = null;
                for (; ; )
                {
                    try
                    {
                        //获取到之前启动的MSTN进程对象,这里加了异常处理是因为MSTN进程启动需要相应的时间。在这段时间里获取msApp会发生异常。所以在这里一直执行
                        //直到不发生异常才跳出循环
                        msApp = (Bentley.Interop.MicroStationDGN.Application)Interaction.GetObject(null,
                           "MicroStationDGN.Application");
                        break;
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                if (null == msApp)
                    return;
                msApp.Visible = false;
                string seedFile = @"D:\CETest.DGN";
                msApp.OpenDesignFile(seedFile, false);
                Point3d[] ptArr = new Point3d[2];
                ptArr[0] = msApp.Point3dZero();
                ptArr[1] = msApp.Point3dFromXYZ(10, 0, 0);
                LineElement lineEle = msApp.CreateLineElement1(null, ptArr);
                msApp.ActiveModelReference.AddElement(lineEle);
                MessageBox.Show("Success");
                msApp.Quit();

    Answer Verified By: fan yang 

Children