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;
Transaction ts = Transaction(uiDoc.Document, );
ts.Start();
Wall wall = uiDoc.Document.GetElement(uiDoc.Selection.PickObject(ObjectType.Element, )) Wall;
Materials materials = doc.Settings.Materials;
ElementId materialId = materials.get_Item().Id;
CompoundStructure cs = wall.WallType.GetCompoundStructure();
CompoundStructureLayer layer = CompoundStructureLayer( / , MaterialFunctionAssignment.Insulation, materialId);
cs.SetLayer(cs.GetFirstCoreLayerIndex(), layer);
IList<CompoundStructureLayer> listLayer = cs.GetLayers();
iIdx = ;
(CompoundStructureLayer cLayer listLayer)
{
(MaterialFunctionAssignment.Structure == cLayer.Function)
{
;
}
iIdx += ;
}
cs.SetLayerWidth(iIdx, / );
wall.WallType.SetCompoundStructure(cs);
ts.Commit();
Result.Succeeded;
}
}url:http://greatverve.cnblogs.com/p/revit-api-CompoundStructure.html