public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uidoc.Document; if (null == doc) { Util.ErrorMsg("Please run this command in a valid" + " Revit project document."); return(Result.Failed); } IEnumerable <ElementId> ids = Util.GetSelectedRooms(uidoc); if ((null == ids) || (0 == ids.Count())) { return(Result.Cancelled); } View view = doc.ActiveView; SpatialElementBoundaryOptions seb_opt = new SpatialElementBoundaryOptions(); Dictionary <int, JtLoops> booleanLoops = new Dictionary <int, JtLoops>( ids.Count <ElementId>()); foreach (ElementId id in ids) { Room room = doc.GetElement(id) as Room; JtLoops loops = ClipperRvt.GetRoomOuterBoundaryLoops( room, seb_opt, view); if (null == loops) // the room may not be bounded { continue; } booleanLoops.Add(id.IntegerValue, loops); } JtWindowHandle hwnd = new JtWindowHandle( uiapp.MainWindowHandle); Util.CreateOutput("room_outer_outline", "Room Outer Outline", doc, hwnd, booleanLoops); return(Result.Succeeded); }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uidoc.Document; if (null == doc) { Util.ErrorMsg("Please run this command in a valid" + " Revit project document."); return(Result.Failed); } ICollection <ElementId> ids = Util.GetSelectedElements(uidoc); if ((null == ids) || (0 == ids.Count)) { return(Result.Cancelled); } // Third attempt: create the element 2D outline // from element solid faces and meshes in current // view by projecting them onto the XY plane and // executing 2d Boolean unions on them. View view = doc.ActiveView; Dictionary <int, JtLoops> booleanLoops = ClipperRvt.GetElementLoops(view, ids); JtWindowHandle hwnd = new JtWindowHandle( uiapp.MainWindowHandle); Util.CreateOutput("element_2d_boolean_outline", "2D Booleans", doc, hwnd, booleanLoops); return(Result.Succeeded); }