Beispiel #1
0
 private void InitData()
 {
     foreach (BuiltInCategory enumCat in Enum.GetValues(typeof(BuiltInCategory)))
     {
         try
         {
             FilteredElementCollector collector = new FilteredElementCollector(Rvt.Handler.Doc);
             ElementCollection        elemC     = new ElementCollection(collector.OfCategory(enumCat).ToList());
             Category category = Category.GetCategory(Rvt.Handler.Doc, enumCat);
             if (elemC != null && elemC.Count > 0 &&
                 category != null && category.CategoryType == CategoryType.Model)
             {
                 AllCategories.Add(new CategoryNode(category, elemC));
             }
         }
         catch { continue; }
     }
 }
        private int Partition(ElementCollection array, int start, int end, bool ascending, SortBy byWhat)
        {
            int marker = start;             //divides left and right subarrays

            for (int i = start; i < end; i++)
            {
                //array[end] is pivot
                if (byWhat == SortBy.InstanceName)
                {
                    if ((ascending == true && array[i].InstanceName.CompareTo(array[end].InstanceName) < 0) ||
                        (ascending == false && array[i].InstanceName.CompareTo(array[end].InstanceName) > 0))
                    {
                        Swap(marker, i);
                        marker += 1;
                    }
                }
                else if (byWhat == SortBy.Type)
                {
                    if ((ascending == true && array[i].Type.CompareTo(array[end].Type) < 0) ||
                        (ascending == false && array[i].Type.CompareTo(array[end].Type) > 0))
                    {
                        Swap(marker, i);
                        marker += 1;
                    }
                }
                else                 // if sort by elements amount
                {
                    if ((ascending == true && array[i].Amount < array[end].Amount) ||
                        (ascending == false && array[i].Amount > array[end].Amount))
                    {
                        Swap(marker, i);
                        marker += 1;
                    }
                }
            }
            // put pivot(array[end]) between left and right subarrays
            Swap(marker, end);
            return(marker);
        }
        public ElementCollection GroupByCategory()
        {
            // Fill a dictionary by elements categories
            Dictionary <string, ElementCollection> categoryDict = new Dictionary <string, ElementCollection>();

            foreach (ElementContainer elemCont in Rvt.Data.PickedElements)
            {
                if (categoryDict.Keys.Contains(elemCont.CategoryName) == false)
                {
                    categoryDict.Add(elemCont.CategoryName, new ElementCollection());
                }
                categoryDict[elemCont.CategoryName].Add(elemCont);
            }

            // Create a new element collection filled by the dictionary order
            ElementCollection groupedCol = new ElementCollection();

            foreach (var pair in categoryDict)
            {
                groupedCol.Add(new ElementContainer(pair.Key));                 // Add category line
                groupedCol.AddElementCollection(pair.Value);                    // Add elements of category
            }
            return(groupedCol);
        }
Beispiel #4
0
 public void InitExportElements()
 {
     ExportElements = new ElementCollection();
 }
Beispiel #5
0
 public CategoryNode(Category category, ElementCollection elements)
 {
     Category = category;
     Elements = elements;
 }