Revit Wall Compound Layer Modification and Query

Always wanted to record some of my problems and solutions with blog. Today is first blog on CSDN, rest will be transferred from Zhihu successively.

Reference Link: https://blog.csdn.net/u010585773/article/details/83267911

In Revit if querying wall thickness data, only need to access WallType. When modifying corresponding thickness need to enter structure layer: CompoundStructure similar to new thickness panel in our usage. It provides methods to create and modify compound layers

WallType type = WallTypes.ElementAt(0) as WallType;
WallType newType = type.Duplicate(name) as WallType;
//Wall Thickness
CompoundStructure cs = type.GetCompoundStructure();
CompoundStructure wallComPound = newType.GetCompoundStructure();
foreach (CompoundStructureLayer layer in wallComPound.GetLayers())
{
layer.Width = value / 304.8;
wallComPound.SetLayerWidth(layer.LayerId, layer.Width);
break;
}
newType.SetCompoundStructure(wallComPound);

After modifying thickness need to pass value back to compound structure to let compound structure parameter of WallType change.