用的是C++
应该是您代码的问题,请上传一下您的测试代码(最好是一个可单独编译执行能复现问题的函数),以及测试文件,
BentleyStatus CreateMeshFromCurve(ElementHandle eh, ICurvePrimitivePtr item, IFacetOptionsPtr pFacetOptionsPtr){ IPolyfaceConstructionPtr pPolygonFace = IPolyfaceConstruction::Create(*pFacetOptionsPtr.get());//IPolyfaceConstruction用于构建多面网格的辅助对象。 MSBsplineCurve bsplineCurve; bool bRes = item->GetMSBsplineCurve(bsplineCurve);
if (!bRes) return SUCCESS; try { if (dRadius < 0.00000001) { //wprintf(L"%f", dRadius);0456.dgn return (BentleyStatus)0; } pPolygonFace->AddTubeMesh(bsplineCurve, dRadius, 0, 1000);
PolyfaceHeaderPtr pPolyMesh = pPolygonFace->GetClientMeshPtr();//返回多面网格 EditElementHandle eeh; DgnModelP pActiveModel = ISessionMgr::GetActiveDgnModelP(); if (SUCCESS == DraftingElementSchema::ToElement(eeh, *pPolyMesh, nullptr, *pActiveModel)) { ElementPropertiesGetterPtr propGetter = ElementPropertiesGetter::Create(eh); UInt32 clrId = propGetter->GetColor(); LevelId lvlId = propGetter->GetLevel(); /*propGetter->GetCableNumber();*/ ElementPropertiesSetterPtr setter = ElementPropertiesSetter::Create(); setter->SetColor(clrId); setter->SetLevel(lvlId); setter->Apply(eeh); eeh.AddToModel(); }
/////////////////////////////添加ItemType ItemTypeLibraryPtr libPtr = ItemTypeLibrary::FindByName(L"Imported Furniture", *ISessionMgr::GetActiveDgnFile()); if (libPtr.IsNull()) { libPtr->Create(L"Imported Furniture", *ISessionMgr::GetActiveDgnFile(),true); } ItemTypeCP sofaItemTypeCPtr = libPtr->GetItemTypeByName(L"Sofa"); Bentley::DgnPlatform::CustomItemHost itemHost(eeh, false); DgnECInstancePtr instancePtr = itemHost.ApplyCustomItem(*sofaItemTypeCPtr); instancePtr->SetValue(L"Type", ECValue(L"Modifed Sofa")); instancePtr->WriteChanges(); ///////////////////////////////////////////测试 } catch (...) { return (BentleyStatus)0; } return SUCCESS;}
0878.dgn
老师,应该就是/////////////////////////////添加ItemType和///////////////////////////////////////////测试,这之间写的代码问题,若是没有这之间的代码,程序可以运行的,加上这一段代码,就提示上面方框的报错问题