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: 

How to collect all elements of given top category?

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Act-3D
4399 Views, 4 Replies

How to collect all elements of given top category?

I can collect all elements of given category Id:

 

ICollection<ElementId> ids = new FilteredElementCollector(doc).OfCategoryId(categoryId).ToElementIds();

But how to collect all elements of given top category?

For example I want to collect all elements of top category "Windows" which means all elements where category is Windows->Glass, Windows->Frame/Mullion etc.

4 REPLIES 4
Message 2 of 5
JimJia
in reply to: Act-3D

Please accept our sincerer apology for the delay! We had a backlog in the queue.
In your case, we suggest you using the enum class Autodesk.Revit.DB.BuiltInCategory.
You can try following code:

ElementFilter windowCategoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_Windows);
ICollection<ElementId> ids = new FilteredElementCollector(doc).WherePasses(windowCategoryFilter).ToElementIds();

Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
Message 3 of 5
Act-3D
in reply to: JimJia

Hi Jim,

 

Thank you for your answer.

 

And what about elements inside a family?

 

For example, in example Revit project rac_basic_sample_project.rvt there is a Curtain wall (see screenchot).

 

It is category: Wall. How to get all elements ids inside this?

Message 4 of 5
matthew_taylor
in reply to: Act-3D

Hi @Act-3D,

The old-fashioned way to do this would be to delete the curtain wall, see which elementIds were deleted, and then rollback the transaction afterwards. (As described for another element type here: http://thebuildingcoder.typepad.com/blog/2010/11/access-to-sketch-and-sketch-plane.html

 

Now, you can probably get all you need by using the properties of Wall.CurtainGrid.

 

Not exactly a filteredElementCollector, but I'm not sure that approach is workable in this instance.

 

Cheers,

 

-Matt


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 5 of 5
Act-3D
in reply to: matthew_taylor

Thank you Matt.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community