Collect all room element from the model

Collect all room element from the model

amir.aroesti
Advocate Advocate
1,223 Views
2 Replies
Message 1 of 3

Collect all room element from the model

amir.aroesti
Advocate
Advocate

Hi,

i read some post here and understand the issue about collecting room.

 

            FilteredElementCollector collector = new FilteredElementCollector(doc);
            ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_Walls);
            IList<Wall> walls = collector.WherePasses(filter).WhereElementIsNotElementType().Cast<Wall>().ToList();
            IList<Element> rooms = collector.OfClass(typeof(SpatialElement)).ToElements();

            StringBuilder sb = new StringBuilder();

            foreach (Wall w in walls)
            {
                sb.AppendLine(string.Format("wall id: {0}", w.Id.ToString()));
            }
            TaskDialog.Show("Test", sb.ToString() + "number of rooms " + rooms.Count().ToString());

 

i tried this but unfortunately dont get any element.

any Idea?

 

0 Likes
1,224 Views
2 Replies
Replies (2)
Message 2 of 3

amir.aroesti
Advocate
Advocate
            ElementCategoryFilter filteroom = new ElementCategoryFilter(BuiltInCategory.OST_Rooms);
            FilteredElementCollector collectoroom = new FilteredElementCollector(doc);
            IList<Element> Crooms = collectoroom.WherePasses(filteroom).WhereElementIsNotElementType().ToElements();

somehow,even though i read that it is not possible to filter category OST.ROOMS it is just work!

0 Likes
Message 3 of 3

TripleM-Dev.net
Advisor
Advisor

What exactly are you telling/stating.

Some posts claim Rooms can't be collected by their Category?

 

FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms);

This works just fine.

WhereElementIsNotElementType not needed as rooms are never a type. (wouldn't reduce collection)