/// <summary> /// Pick Faces in the current Revit Document. Don't forget to hit the Finished button in the options bar. /// </summary> /// <param name="message">A message to be displayed in the status bar.</param> /// <param name="reset">Resets the node so one can pick new objects.</param> /// <returns name="Faces">List of the selected faces.</returns> public static List <DynElem> Faces( [DefaultArgument("Select elements")] string message, [DefaultArgument("true")] bool reset) { Autodesk.Revit.UI.UIApplication uiapp = DocumentManager.Instance.CurrentUIApplication; RevitDoc doc = DocumentManager.Instance.CurrentDBDocument; List <DynElem> elems = new List <DynElem>(); revitSelect.Selection selection = uiapp.ActiveUIDocument.Selection; try { IList <Reference> references = selection.PickObjects(revitSelect.ObjectType.Face, message); foreach (Reference r in references) { DynElem elem = doc.GetElement(r.ElementId).ToDSType(true); elems.Add(elem); } } catch (Autodesk.Revit.Exceptions.OperationCanceledException e) { return(null); } return(elems); }
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; //access to the Revit selection methods Autodesk.Revit.UI.Selection.Selection sel = uidoc.Selection; //provides a filtered selection ElementMulticategoryFilter multicategoryFilter = new ElementMulticategoryFilter(TargetCategories()); var filter = Utilities.SelFilter.GetElementFilter(multicategoryFilter); //prompt the user for a selection IList <Reference> selectionReference; try { selectionReference = sel.PickObjects(ObjectType.Element, filter); } catch (Exception) { //land here if someone cancels the pick operation return(Result.Cancelled); } //try to export to JSON on the desktop bool result = RevitElementsToHypar(doc, selectionReference.Select(e => e.ElementId).ToList()); if (result) { return(Result.Succeeded); } return(Result.Failed); }