老师我这里创建named boundary 每次都会崩溃.这个根据shap单个创建named boundary 有什么问题吗?还是我创建的方式不对
void create_nameboundary111(Transform* transform){ MSElementP el; MSElement el1; DPoint3d pts[4]; NamedBoundaryPtr namedptr;
EditElementHandle eehShape; ElementHandle eehShape1; WStringP namegroup = new WString(L"namerdgroup"); DgnModelR modelR = *ISessionMgr::GetActiveDgnModelP(); /*named boundary 集合*/ NamedBoundaryGroupPtr boundarygrop = NamedBoundaryGroup::Create(modelR, *namegroup, *namegroup); pts[0].x = 1000* g_1mu; pts[0].y = 0* g_1mu;
pts[1].x = 8000* g_1mu; pts[1].y = 0* g_1mu;
pts[3].x = 8000* g_1mu; pts[3].y = 7000* g_1mu;
pts[2].x = 1000* g_1mu; pts[2].y = 7000* g_1mu;
if (SUCCESS == ShapeHandler::CreateShapeElement(eehShape, NULL, pts, 4, ACTIVEMODEL->Is3d(), *ACTIVEMODEL)) { el = eehShape.GetElementP(); mdlElement_transform(&el1, el, transform); //eehShape eehShape.ReplaceElement(&el1); eehShape.AddToModel(); /*创建namedboundary 加入named boundary group*/
//namedptr = NamedBoundary::Create(eehShape/*元素*/);创建出来的named boundary 一直为空
NamedBoundary* newBoundaryx = new NamedBoundary();
newBoundaryx->SetGraphicalElement(eehShape);
newBoundaryx->SetName(L"name"); boundarygrop->InsertBoundary(newBoundaryx); boundarygrop->WriteToFile(); }
}
如下测试代码可以顺利通过:
void createNamedBoundary(WCharCP) { DPoint3d pts[4] = { {0,0,0}, {1000,0,0}, {1000, 500,0}, {0,500,0} }; EditElementHandle eeh; ShapeHandler::CreateShapeElement(eeh, nullptr, pts, 4, ACTIVEMODEL->Is3d(), *ACTIVEMODEL); eeh.AddToModel(); NamedBoundaryPtr pBoundary = NamedBoundary::Create(); pBoundary->SetModelRef(ACTIVEMODEL); pBoundary->SetName(L"MyNamedBoundary"); pBoundary->SetDrawingScale(1.0); pBoundary->SetGraphicalElement(eeh); pBoundary->Save(); }
Answer Verified By: chen chen
感谢老师问题已解决