对于 大多数 i.dgn文件可以正常获取对象颜色,但对于一些特别的i.dgn文件,不能获取到其在msce中显示的颜色,浏览过其他提问,(https://communities.bentley.com/communities/other_communities/chinafirst/f/microstation-projectwise/136282/thread?ReplySortBy=CreatedDate&ReplySortOrder=Ascending)
发现错误的材质都有材料,样式定义这些属性,请问有没有一种方法可以在msce中获取这类数据正确的颜色?
试试这个函数: mdlElement_getEffectiveSymbology
试了这个方法,也不能获得正确的结果,最后两个参数给的nullptr 和 0
这个方法有很多时候获取的都是黑色,不知道啥原因
能否提供一下您的模型文件,并说明一下是哪个元素获取不到正确颜色。
微信发你了,郭工帮忙看下
您试试用下面代码获取看看:
SymbologyReporter symbReporter(eh); UInt32 clrId, clrIdx; bool isTrueClr; WString bookName, clrName; double transparency; UInt index = 0; while (SUCCESS == symbReporter.GetColorID(clrId, index)) index++; index--; symbReporter.GetTransparency(transparency, index); if (COLOR_BYLEVEL == clrId) { LevelId lvlID; symbReporter.GetLevelId(lvlID, index); LevelCacheR lvlCache = eh.GetDgnModelP()->GetLevelCacheR(); LevelHandle lvlHandle = lvlCache.GetLevel(lvlID); clrId = lvlHandle.GetByLevelColor().GetColor(); } DgnColorMapP pClrMap = DgnColorMap::GetForDisplay(eh.GetDgnModelP()); IntColorDef clrDef = pClrMap->GetColor(clrId); pClrMap->ExtractElementColorInfo(&clrDef, &clrIdx, &isTrueClr, &bookName, &clrName, clrId, *eh.GetDgnFileP()); value["colors"].append((double)clrDef.m_rgb.red/255); value["colors"].append((double)clrDef.m_rgb.green/255); value["colors"].append((double)clrDef.m_rgb.blue/255); value["colors"].append(1.0 - transparency);