Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Filter Family Symbols which has Instance Placed in the Project Model

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
1512 Views, 2 Replies

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

Filter Family Symbols which has Instance Placed in the Project Model

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?

 

2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

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

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);

Message 3 of 3
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

 

Thanks Peterjegan

 

It works


You deserve the compliments

0 Likes

 

Thanks Peterjegan

 

It works


You deserve the compliments

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report