- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all,
I am Revit API begginer and I am trying to make a macro that applies a value to an elements parameter deppending in which area it is.
For example if I have a door in one area that I called "zone 01" I want the parameter to be that.
If there is a wall that goes through zone 01 and zone 02 I want the parameter to be "zone 01, zone 02"
At the moment my strategy is to generate volumes that represent this areas and the filter the elements that intersect them.
However I can not make my code to work.
When the element is in zone 01 it works and when it goes throug zone 1 and zone 2 it works as well.
However if the element is only in zone 02 it doesnt work, the parameter remains empty.
The model is just a couple of walls and doors and the volumes intersect propperly.
If I "comment" filter1 and filter12 it works for zone 2!
I pretend to make this or 6 areas in total.
Any help will be appreciated.
Here is my attempt:
public void ConstructionArea() { UIDocument uidoc = this.ActiveUIDocument; Document doc = uidoc.Document; //get selection from revit ICollection<ElementId> myids = uidoc.Selection.GetElementIds(); //collector FilteredElementCollector collector = new FilteredElementCollector(doc,myids); //set zone elements IDs ElementId z1Id = new ElementId(197634); Element z1 = doc.GetElement(z1Id); ElementId z2Id = new ElementId(197723); Element z2 = doc.GetElement(z2Id); //filters ElementIntersectsElementFilter filter1 = new ElementIntersectsElementFilter(z1); ElementIntersectsElementFilter filter2 = new ElementIntersectsElementFilter(z2); //logical filters IList<ElementFilter> flist12 = new List<ElementFilter>{filter1,filter2}; LogicalAndFilter filter12 = new LogicalAndFilter(flist12); //collector filter ICollection<Element> elements1 = collector.WherePasses(filter1).ToElements(); ICollection<Element> elements2 = collector.WherePasses(filter2).ToElements(); IList<Element> elements12 = collector.WherePasses(filter12).ToElements(); using (Transaction t = new Transaction(doc,"construction area")) { t.Start(); //iterate foreach (Element e in elements1) { Parameter mypara = e.LookupParameter("test"); mypara.Set("zone 01"); } foreach (Element e in elements2) { Parameter mypara = e.LookupParameter("test"); mypara.Set("zone 02"); } foreach (Element e in elements12) { Parameter mypara = e.LookupParameter("test"); mypara.Set("zone 01, zone 02"); } t.Commit(); } }
Solved! Go to Solution.