public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { Document doc = commandData.Application.ActiveUIDocument.Document; Selection selection = commandData.Application.ActiveUIDocument.Selection; SpatialElementBoundaryOptions opt = new SpatialElementBoundaryOptions(); ModelCurveCreator mmc = new ModelCurveCreator(doc); IList <Reference> rooms = selection.PickObjects(ObjectType.Element, new RoomFilter(), "Выберите помещения"); try { using (Transaction tr = new Transaction(doc, "Создание контуров")) { tr.Start(); foreach (Reference roomref in rooms) { CurveArray curves = new CurveArray(); SpatialElement room = doc.GetElement(roomref.ElementId) as SpatialElement; foreach (var boundary in CurveUtils.GetCurvesListFromSpatialElement(room)) { foreach (var curve in boundary) { curves.Append(curve); } } mmc.DrawGroup(curves, string.Format("Контур {0} #{1}", room.Category.Name, room.Number)); } TaskDialog.Show("Результат", "Создано групп контуров: " + rooms.Count.ToString()); tr.Commit(); } } catch { return(Result.Failed); } return(Result.Succeeded); }