Message 1 of 3
Not able to change width of layer of compound structure of roof?

Not applicable
08-24-2018
03:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I tried several ways to change width of layer of roof, but no luck, here is my code, and attachment if my sample file:
[TransactionAttribute(TransactionMode.Manual)] public class Class1 : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { var doc = commandData.Application.ActiveUIDocument.Document; ExtrusionRoof filteredElement = null; var filteredElementFilter = new ElementClassFilter(typeof(ExtrusionRoof)); FilteredElementCollector filteredElements = new FilteredElementCollector(doc); filteredElements = filteredElements.WherePasses(filteredElementFilter); using (Transaction transaction = new Transaction(doc)) { try { if (transaction.Start("update roof width") == TransactionStatus.Started) { foreach (ExtrusionRoof element in filteredElements) { var elementType = doc.GetElement(element.GetTypeId()) as RoofType; if (elementType != null) { var cs = elementType.GetCompoundStructure(); var layers = cs.GetLayers(); foreach (var layer in layers) { layer.Width = 0.0328; //10mm, not work break; } //cs.SetLayerWidth(0, 0.0328); // not work //cs.SetLayers(layers); // not work break; } } transaction.Commit(); } else { TaskDialog.Show("ERROR", "Start transaction 'update roof width' failed!"); } } catch (Exception ex) { TaskDialog.Show("ERROR", ex.ToString()); if (transaction.GetStatus() == TransactionStatus.Started) transaction.RollBack(); } } return Result.Succeeded; } }