public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication app = commandData.Application;
UIDocument uidoc = app.ActiveUIDocument;
Document doc = uidoc.Document;
List<Element> rooms = new List<Element>();
if( !Util.GetSelectedElementsOrAll(
rooms, uidoc, typeof( Room ) ) )
{
Selection sel = uidoc.Selection;
message = ( 0 < sel.GetElementIds().Count )
? "Please select some room elements."
: "No room elements found.";
return Result.Failed;
}
using ( Transaction t = new Transaction( doc ) )
{
t.Start( "Bump Room Occupancy" );
foreach ( Room room in rooms )
{
BumpOccupancy( room );
}
t.Commit();
}
return Result.Succeeded;
}