Hi,
I've got some problems when I copy elements with items and labels from a reference file. The elements, items and labels a copied but extra cell elements with the label text are added too.
I've attached a design file that contains two models: a design model and sheet model in which I've attached the design model as reference.
(Please visit the site to view this file)
If you run the code listed below you will see the problem.
// create shape element DPoint3d pts[5]; pts[0].x = pts[0].y = 0; pts[1].x = 500; pts[1].y = 0; pts[2].x = 500; pts[2].y = 500; pts[3].x = 0; pts[3].y = 500; pts[4].x = pts[4].y = 0; for (int i = 0; i < 5; i++) pts[i].z = 0; EditElementHandle eehShape; ShapeHandler::CreateShapeElement(eehShape, NULL, pts, 5, true, *ISessionMgr::GetActiveDgnModelRefP()); // define fence by shapeElement IndexedViewSetR viewSet = IViewManager::GetManager().GetActiveViewSet(); FenceManagerR fenceManager = FenceManager::GetManager(); fenceManager.DefineByElement(&eehShape, viewSet.GetViewport(tcb->lstvw)); FenceParamsP fenceParams = FenceParams::Create(ISessionMgr::GetActiveDgnModelP()); fenceManager.InitFromActiveFence(*fenceParams, false, false, FenceClipMode::None); // build modelreflist DgnModelRefListP modelRefList; mdlModelRefList_create(&modelRefList); mdlModelRefList_add(modelRefList, ISessionMgr::GetActiveDgnModelP()); ModelRefIteratorP mrIteratorP; if (mdlModelRefIterator_create(&mrIteratorP, mdlModelRef_getActive(), MRITERATE_Root | MRITERATE_PrimaryChildRefs, -1) == SUCCESS) { DgnModelRefP modelRef = mdlModelRefIterator_getFirst(mrIteratorP); while (modelRef) { mdlModelRefList_add(modelRefList, modelRef); modelRef = mdlModelRefIterator_getNext(mrIteratorP); } mdlModelRefIterator_free(&mrIteratorP); } // build element agenda and free modelreflist ElementAgenda elmAgenda; fenceManager.BuildAgenda(*fenceParams, elmAgenda, modelRefList, false, false, false); mdlModelRefList_free(&modelRefList); // copy the elements in the elementAgenda ElementCopyContext elmCopyContext(ISessionMgr::GetActiveDgnModelP()); elmCopyContext.SetLevelHandling(CopyContextLevelOption::CopyIfNotFound); for (UInt index = 0; index < elmAgenda.GetCount(); index++) { EditElementHandleP eehP = elmAgenda.GetEntryP(index); elmCopyContext.DoCopy(*eehP); eehP->AddToModel(); }
Any ideas to solve this problem ?
TIA, Evan