Get Zones (and their Spaces) by Level

Get Zones (and their Spaces) by Level

iliasmitmail
Contributor Contributor
496 Views
1 Reply
Message 1 of 2

Get Zones (and their Spaces) by Level

iliasmitmail
Contributor
Contributor

Hallo Everyone,

 

for some reason I am having a hard time with getting my Zones in a Project sorted by the level they are on.

I tried in two different ways, but none work.

 

I would be very happy if you could help me out.

 

Here are the two variations that I tried:

public static BindingList<ClassZone> getZones(Level floor)
        {
            BindingList<ClassZone> czones = new BindingList<ClassZone>();

            try
            {
//Variant Number 1:
                // Find all Zone elements
                ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_HVAC_Zones);
                // Apply the filter to the elements in the active document
                FilteredElementCollector collector = new FilteredElementCollector(_doc);
                IList<Element> zones = collector.WherePasses(filter).WhereElementIsNotElementType().ToElements();

//Variant Number 2:
                
                IEnumerable<Element> zones = new FilteredElementCollector(_doc) //search only in this level
                .OfClass(typeof(Element)).Where(zone => zone.GetType() == typeof(Autodesk.Revit.DB.Mechanical.Zone)).Cast<Element>().Where(o => o.LevelId == floor.Id);



                foreach (Element z in zones)
                {
                    if (z.LevelId == floor.LevelId)
                    {

                        ClassZone czone = parseZone((Zone)z);

                        if (czone != null)
                        {
                            czones.Add(czone);
                        }
                        else
                        {
                            TaskDialog.Show("Zonen Fehler!!", "The Number of Zones on the Floor = 0");
                        }
                    }
                }
            }
            catch(Exception e)
            {
                TaskDialog.Show("Fehler bei den Zones", e, TaskDialogCommonButtons.Ok);
            }
            return czones;
        }
0 Likes
497 Views
1 Reply
Reply (1)
Message 2 of 2

iliasmitmail
Contributor
Contributor

Neverminde, it took me some time but I got it.

 

However, I am wondering if their is a way to delete this Post?

0 Likes