Hi everyone,
I am in need of creating a filter which can satisfy both of 2 conditions below:
1. Family symbols in a certain category
2. Has instance placed in the project model
For instance: I say there are 2 family symbols (Type 1 and Type 2) in a family which belongs to Structural Columns category. Among these 2 family symbols, only Type 1 has instances placed in the project model, and Type 2 has not. And now I want to create a filter in order to filter out the Type 1 only.
I came across the below link:
http://help.autodesk.com/view/RVT/2015/ENU/?guid=GUID-A2686090-69D5-48D3-8DF9-0AC4CC4067A5
and found that it is quite easy to create the filter satisfying the 1st condition as below:
ElementCategoryFilter categoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_StructuralColumns); ElementClassFilter familySymbolFilter = new ElementClassFilter(typeof(FamilySymbol)); LogicalAndFilter logicalAndFiter = new LogicalAndFilter(categoryFilter,familySymbolFilter); FilteredElementCollector collector = new FilteredElementCollector(doc).WherePasses(logicalAndFiter);
But now I am stuck on creating the filter to satisfy both of 2 conditions
Any advice on this issue?
Solved! Go to Solution.
Hi everyone,
I am in need of creating a filter which can satisfy both of 2 conditions below:
1. Family symbols in a certain category
2. Has instance placed in the project model
For instance: I say there are 2 family symbols (Type 1 and Type 2) in a family which belongs to Structural Columns category. Among these 2 family symbols, only Type 1 has instances placed in the project model, and Type 2 has not. And now I want to create a filter in order to filter out the Type 1 only.
I came across the below link:
http://help.autodesk.com/view/RVT/2015/ENU/?guid=GUID-A2686090-69D5-48D3-8DF9-0AC4CC4067A5
and found that it is quite easy to create the filter satisfying the 1st condition as below:
ElementCategoryFilter categoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_StructuralColumns); ElementClassFilter familySymbolFilter = new ElementClassFilter(typeof(FamilySymbol)); LogicalAndFilter logicalAndFiter = new LogicalAndFilter(categoryFilter,familySymbolFilter); FilteredElementCollector collector = new FilteredElementCollector(doc).WherePasses(logicalAndFiter);
But now I am stuck on creating the filter to satisfy both of 2 conditions
Any advice on this issue?
Solved! Go to Solution.
I would find all instances and then find the types:
Like this:
ElementCategoryFilter strCategoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_StructuralColumns); FilteredElementCollector strCollector = new FilteredElementCollector(doc); //store instances IList<Element> strColInstances = strCollector.WherePasses(strCategoryFilter).WhereElementIsNotElementType().ToElements(); //create list and string variable to store types in use IList<ElementId> typesInUse = new List<ElementId>(); string types = "Type Names:" +Environment.NewLine; foreach (Element el in strColInstances) { ElementId typeId = el.GetTypeId(); if (!typesInUse.Contains(typeId)) { typesInUse.Add(typeId); types += doc.GetElement(typeId).Name + Environment.NewLine; } } string prompt = "Total types in use: " + typesInUse.Count.ToString() + Environment.NewLine + types; TaskDialog.Show("Revit", prompt);
I would find all instances and then find the types:
Like this:
ElementCategoryFilter strCategoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_StructuralColumns); FilteredElementCollector strCollector = new FilteredElementCollector(doc); //store instances IList<Element> strColInstances = strCollector.WherePasses(strCategoryFilter).WhereElementIsNotElementType().ToElements(); //create list and string variable to store types in use IList<ElementId> typesInUse = new List<ElementId>(); string types = "Type Names:" +Environment.NewLine; foreach (Element el in strColInstances) { ElementId typeId = el.GetTypeId(); if (!typesInUse.Contains(typeId)) { typesInUse.Add(typeId); types += doc.GetElement(typeId).Name + Environment.NewLine; } } string prompt = "Total types in use: " + typesInUse.Count.ToString() + Environment.NewLine + types; TaskDialog.Show("Revit", prompt);
Thanks Peterjegan
It works
You deserve the compliments
Thanks Peterjegan
It works
You deserve the compliments
Can't find what you're looking for? Ask the community or share your knowledge.