关于ORD导入cell时异常崩溃的问题(在MicroStation上测试没有问题)

写了一个函数测试道岔模型的导入,但是在导入的时候ORD会异常崩溃,代码如下:

		/// <summary>
        /// 测试道岔建模
        /// </summary>
        public static void TestTurnoutModeling()
        {
            try
            {
                Bentley.Interop.MicroStationDGN.Application msApp = Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp;
                // 读取设备配置信息
                XmlNode rootNode = XmlTools.GetFacilityRootNode();
                //XmlNode turnoutNodeLeft = XmlTools.GetFacilityByName(rootNode, NameResources.ItemType_ATF_NO18TurnOutLeftInformation);
                //XmlNode turnoutNodeRight = XmlTools.GetFacilityByName(rootNode, NameResources.ItemType_ATF_NO18TurnOutRightInformation);
                BIM.Point3d position1 = new BIM.Point3d();
                position1.X = 0;
                position1.Y = 469450;
                position1.Z = 3455;
                BIM.Point3d position2 = new BIM.Point3d();
                position2.X = 0;
                position2.Y = 469600;
                position2.Z = 3455;
                BIM.Point3d scalePoint = new BIM.Point3d();
                scalePoint.X = 1; scalePoint.Y = 1; scalePoint.Z = 1;
                // 需要根据角度设置道岔旋转角,包括水平与垂直转角,Matrix3d为旋转矩阵
                BIM.Matrix3d matrizIdentidad = msApp.Matrix3dIdentity(); // 无任何旋转
                // 构建三维模型
                Element element1 = CreateNormalCell("F:\\18号单开道岔单开道岔道床组装图-左开.dgn",
                    "18号左开道岔", position1, scalePoint, matrizIdentidad);
                // 构建三维模型
                Element element2 = CellTCreateNormalCell("F:\\18号单开道岔单开道岔道床组装图-右开.dgn",
                    "18号右开道岔", position2, scalePoint, matrizIdentidad);
            }
            catch (Exception ex)
            {
                MessageBox.Show("股道建模错误:" + ex.ToString());
            }
        }
		
		/// <summary>
        /// 将一个dgn文件中的构建模板导入到指定坐标点位置
        /// </summary>
        /// <param name="dgnPath"></param>
        /// <param name="cellName"></param>
        /// <param name="point">指定坐标点</param>
        /// <param name="scalePoint"></param>
        /// <param name="matrizIdentidad"></param>
        public static Element CreateNormalCell(string dgnPath, string cellName, BIM.Point3d point, BIM.Point3d scalePoint, BIM.Matrix3d matrizIdentidad)
        {
            Bentley.Interop.MicroStationDGN.Application msApp = Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp;
            msApp.AttachCellLibrary(dgnPath);
            BIM.CellElement cellEle = msApp.CreateCellElement2(cellName, ref point, ref scalePoint, true, ref matrizIdentidad);
            // cellElement转普通element
            long cellElePtr = cellEle.MdlElementDescrP();
            Element elem = ORDCellTools.ConvertToDgnNetEle(cellEle);
            elem.AddToModel();
            return elem;
        }

CreateNormalCell这个函数是根据选择的Cell文件将模型插入到固定的位置上。这个函数被调用了两次,分别导入两种道岔模型。

目前经过调试,发现是在第二个CreateNormalCell这一句会导致ORD崩溃,崩溃的时候ORD没有任何报错,这个异常同时也捕获不到,ORD就直接自动关闭了。

经过调试,程序崩溃在CreateNormalCell函数的elem.AddToModel()这一句。

但是如果让两个CreateNormalCell都调用同一个dgn文件(F:\\18号单开道岔单开道岔道床组装图-左开.dgn)的时候,代码就可以正常执行且导入文件。

此外,我在MicroStation上也测试了上述代码,能够同时导入两种道岔不会报错。

Parents Reply Children
No Data