Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Filter Family Symbols which has Instance Placed in the Project Model

Anonymous

Filter Family Symbols which has Instance Placed in the Project Model

Anonymous
Not applicable

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?

 

0 Likes
Reply
Accepted solutions (1)
1,568 Views
2 Replies
Replies (2)

Anonymous
Not applicable
Accepted 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);

0 Likes

Anonymous
Not applicable

 

Thanks Peterjegan

 

It works


You deserve the compliments

0 Likes