예제 #1
0
        /// <summary>
        /// PickObject Element Multiply Categories
        /// Show Information Element
        /// </summary>
        /// <param name="commandData"></param>
        /// <param name="message"></param>
        /// <param name="elements"></param>
        /// <returns></returns>
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            #region Init

            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            #endregion

            try
            {
                CategoryFilter categoryFilter = new CategoryFilter {
                    catname = "Walls"
                };
                IList <Reference> references = uidoc.Selection.PickObjects(ObjectType.Element, categoryFilter,
                                                                           "Select Element Filter By Categories ");
                StringBuilder sb = new StringBuilder();
                foreach (Reference r in references)
                {
                    Autodesk.Revit.DB.Element e = doc.GetElement(r);
                    sb.AppendLine($"{e.Name}-{e.Id}");
                }
                MessageBox.Show($"{sb}");
            }
            catch (Autodesk.Revit.Exceptions.OperationCanceledException) {}
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            return(Result.Succeeded);
        }