[MSCE C++]在MSCE中有时不能正确读取imodel中的构件颜色

对于 大多数 i.dgn文件可以正常获取对象颜色,但对于一些特别的i.dgn文件,不能获取到其在msce中显示的颜色,浏览过其他提问,(https://communities.bentley.com/communities/other_communities/chinafirst/f/microstation-projectwise/136282/thread?ReplySortBy=CreatedDate&ReplySortOrder=Ascending)

发现错误的材质都有材料,样式定义这些属性,请问有没有一种方法可以在msce中获取这类数据正确的颜色?

Parents Reply
  • 您试试用下面代码获取看看:

    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);
    
    
    
    

Children
No Data