start
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
cmd : IExternalCommand
{
Result Execute(ExternalCommandData cmdData, msg, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
Document doc = uiDoc.Document;
Selection selection = uiDoc.Selection;
Transaction ts = Transaction(doc, .ToString());
ts.Start();
Reference refWall = selection.PickObject(ObjectType.Element, );
Wall wall = doc.GetElement(refWall) Wall;
WallType wallType = wall.WallType;
CompoundStructure cs = wallType.GetCompoundStructure();
bHas = ; iWidth = ; IList<CompoundStructureLayer> layers = cs.GetLayers(); (CompoundStructureLayer layer layers)
{
(layer.Function == MaterialFunctionAssignment.Insulation) {
bHas = ;
layer.Width = iWidth / ;
}
}
(!bHas) {
CompoundStructureLayer newLayer = CompoundStructureLayer();
newLayer.Function = MaterialFunctionAssignment.Insulation;
newLayer.Width = iWidth / ;
layers.Insert(, newLayer);
}
cs.SetLayers(layers);
wallType.SetCompoundStructure(cs);
ts.Commit();
Result.Succeeded;
}
}url:http://greatverve.cnblogs.com/p/revit-api-CompoundStructureLayer.html