Start
[Transaction (TransactionMode. Manual)]
[Regeneration (RegenerationOption. Manual)]
Cmd: IExternalCommand
{
Result Execute (ExternalCommandData upload data, msg, ElementSet elements)
{
UIDocument uiDoc = upload data. 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 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