注意:结构层的信息一定要设置,如果显示为按类别,其实是没有设置材质的,就不会返回
private void ReadWallLayer()
{
string info = null;
Reference wallRef = uidoc.Selection.PickObject(ObjectType.Element);
Wall wall = doc.GetElement(wallRef) as Wall;
if(wall!=null)
{
CompoundStructure cs = wall.WallType.GetCompoundStructure();
IList<CompoundStructureLayer> csls = cs.GetLayers();
foreach(CompoundStructureLayer csl in csls)
{
if (csl.MaterialId != ElementId.InvalidElementId)
{
Material m = doc.GetElement(csl.MaterialId) as Material;
if (m != null)
{
info += m.Name + "\n";
}
}
}
}
MessageBox.Show(info);
}
博主会经常更新一些技术文章,请大家多多关注,多多交流
更多技术交流,请加qq群480950299