各位老师,在ORD旗舰版中出现了插入单元软件崩溃的问题,在原来的10.08版本就不会,请老师帮忙看看是什么问题导致的, 谢谢

0564.测试.zip在ORD旗舰版中出现了插入多个单元软件直接崩退的问题,也不会报错,在原来的ORD 10.08版本中就没有出现过这种情况,这是我的测试代码和文件,请各位老师帮忙看看是什么问题导致的, 谢谢

Parents Reply
  • 换用PInvoke技术调用c/c++的函数来完成从单元库中放置单元的工作吧,COM接口可能在这种频繁调用的情况下有些问题。

    [DllImport("ustation.dll")]
            public unsafe static extern uint mdlCell_placeCell(DPoint3d* rOrigin, DPoint3d* scale, bool trueScale, DMatrix3d* rotMatrix, short* attributes, uint ggroup,
                bool relativeMode, uint baseLevel, int sharedFlag, long cellName, long library);
            [DllImport("ustation.dll")]
            public unsafe static extern uint mdlElmdscr_read(long* elemDescrPP, uint filePos, long modelRef, int expandSharedCells, uint* readFilePos);
             
            public unsafe static void TempFunction()
            {
                MsApp.AttachCellLibrary(@"D:\CellLib1.dgn");
                DPoint3d rOrigin = DPoint3d.Zero;
                DPoint3d scale = new DPoint3d(1, 1, 1);
                DMatrix3d rotMatrix = DMatrix3d.Identity;
                string cellName = "MyCell1";
                IntPtr intPtr = Marshal.StringToHGlobalUni(cellName);
                uint filePos = mdlCell_placeCell(&rOrigin, &scale, false, &rotMatrix, null, 0, false, 0, 0, intPtr.ToInt64(), 0);
                long elmdscr;
                mdlElmdscr_read(&elmdscr, filePos, Session.Instance.GetActiveDgnModel().GetNative().ToInt64(), 0, null);
                BIM.Element cellEle = MsApp.MdlCreateElementFromElementDescrP(elmdscr);
                MessageBox.Show(cellEle.ID.ToString());
                Marshal.FreeHGlobal(intPtr);
            }

Children