[C++ CE MS ]如何修改共享单元,将共享单元中某一个元素进行修改后再刷新此共享单元,能否给出具体代码示例?

DgnFileP pDgnFile = ISessionMgr::GetActiveDgnFile();
auto sharedCellQuery = dynamic_cast<ISharedCellQuery *>(&elm->GetHandler());
ElementRefP refP = sharedCellQuery->GetDefinition(*elm, *pDgnFile);
if (NULL != refP)
{
EditElementHandle eleshared(refP);

修改eleshared后再ReplaceInModel没有反应。

但是通过以下方法添加元素进去,又有东西

DSegment3d segment = DSegment3d::From({ 0,0,0 }, { 0,0, 30000 });
EditElementHandle lineEeh;
LineHandler::CreateLineElement(lineEeh, NULL, segment, true, *ACTIVEMODEL);

//Create an ellipse
EditElementHandle circleEeh;
if (!createCircleShapeElement(circleEeh, { 0,0,0 }, 10000, { 0,0,1 }))
return;

SharedCellDefHandler::AddChildElement(eleshared, lineEeh);
SharedCellDefHandler::AddChildElement(eleshared, circleEeh);
SharedCellDefHandler::AddChildComplete(eleshared);
if (eleshared.IsValidif )
{
eleshared.ReplaceInModel(eleshared.GetElementRef());
}
if (SharedCellHandler::CreateSharedCellComplete(*elm) != SUCCESS)
{
mdlDialog_dmsgsPrint(L"CreateSharedCellComplete Error.");
return;
}
elm->ReplaceInModel(elm->GetElementRef());
}

需要实现效果,将此共享单元下模型孔去掉,完成后还要是共享单元,且属性不变(普通单元已经实现,目前共享单元修改后,没有效果)。

Parents Reply Children
No Data