public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication app = commandData.Application;
UIDocument uidoc = app.ActiveUIDocument;
Document doc = uidoc.Document;
// retrieve selected floors, or all floors, if nothing is selected:
List <Element> floors = new List <Element>();
if (!Util.GetSelectedElementsOrAll(
floors, uidoc, typeof(Floor)))
{
Selection sel = uidoc.Selection;
message = (0 < sel.GetElementIds().Count)
? "Please select some floor elements."
: "No floor elements found.";
return(Result.Failed);
}
Options opt = app.Application.Create.NewGeometryOptions();
List <List <XYZ> > polygons
= GetFloorBoundaryPolygons(floors, opt);
int n = polygons.Count;
Debug.Print(
"{0} boundary loop{1} found.",
n, Util.PluralSuffix(n));
Creator creator = new Creator(doc);
using (Transaction t = new Transaction(doc))
{
t.Start("Draw Slab Boundaries");
creator.DrawPolygons(polygons);
t.Commit();
}
return(Result.Succeeded);
}