[MSCE]C# 材质问题

符老师,有什么函数可以获取材质图片的地址吗?

还有当材质的颜色选择使用元素颜色时,怎么能得到元素的RGB值,之前找到的颜色都是一个uint或者double的值

  • 如下代码所示可以获取到材质的贴图文件的路径:

    	MaterialMapCP map = m_MaterialCP->GetSettings().GetMaps().GetMapCP(MaterialMap::MAPTYPE_Pattern);
    	if (map != NULL)
    	{
    		MaterialMapLayerCR          topLayer = map->GetLayers().GetTopLayer();
    		const wchar_t* pWchar = MaterialManager::GetManagerR().FindTexture(topLayer.GetImageMapMonikers()[0]->GetPackageName().c_str(), ACTIVEMODEL->GetDgnFileP()).c_str();
    	}
    		

    m_MaterialCP是一个Material的指针,这个如何获取可以参考一下SDK下的这个例子:C:\Program Files\Bentley\MicroStationCONNECTSDK\examples\Visualization\MaterialsExample

    元素颜色的话以前好几个帖子讨论过的,您可以搜一下以前的帖子看看

  • 目前只找到C++部分,您可以参考下,其中最后通过DgnColorMap::ExtractElementColorInfo可以获得clrDef,clrDef.m_rgb.red就是R,clrDef.m_rgb.green就是G,clrDef.m_rgb.blue就是B:

    	UInt32       clrId, clrIdx;
        bool         isTrueClr;
        WString      bookName, clrName;
    	LevelId lvlID;
    	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());

    Answer Verified By: xz h