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

All model elements in project

Message 1 of 5
2869 Views, 4 Replies

All model elements in project


I am trying to search and find all elements that are actually modelled in my project (walls, doors, beam, etc).

From this i will search all elements to find there category and write these to a list.


So far my code is:

List<string> catlist = new List<string>();      

FilteredElementCollector col = new FilteredElementCollector(doc, doc.ActiveView.Id);
            foreach (Element e in col)
                Category cat = e.Category;
                if (call.CategoryType == CategoryType.Model)

I am using the If(call.categorytype == categorytype.model) to try and filter out all non model items but the list still contains things like cameras which i dont want.



Any advice on a better way of achieving this greatly received!!!



Message 2 of 5

Hi Mike,

Your code is only checking the active view and will not get everything in the model, but perhaps you already knew that. In call.CategoryType == CategoryType.Model. What is "call" in your code, did you mean cat? Seems like all elements pass this condition for you.



There are a bunch of other ways to do this, maybe you could use a multicategory filter to fetch the categories you want.

Keep in mind that getting every element of CategoryType.Model(Familyinstances) will get every Curtainwall mullion, panel etc as well, which can be a pretty long list. But I assume you will clean up that list in the end 🙂


Good luck



Message 3 of 5

Dear Mike and Martin,


Thank you for your query and helpful answer.


Yes, indeed, more than a bunch of other ways, I would say the number is absolutely infinite.


I am also confused by the sample code you present, since it neither compiles nor makes any sense.


However, luckily for you, a number of approaches to solve this very issue have been presented by The Building Coder in the topic group on filtering for all elements:


I just updated the links under 'Selecting Model Elements or Visible 3D Elements' for you.


I hope this helps.


Best regards,



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 4 of 5
in reply to: Anonymous

Hi Martin,

Thanks for your answer.

Yes i was aware it was only checking active view but forgot to mention that in my post.

My mistake, as you say "call" should in fact be "cat"


Everything works fine and i am happy tidying up the list after but i just thought there might be a better way of doing it.

The "if (cat.CategoryType == CategoryType.Model)" seems to pick up things like camera's which in my mind arent model elements...


thanks for clarifying i wasnt completely off the ball and my solution is ok.



Message 5 of 5

Hi Jeremy,


Dont know why my code doesnt work for you, did you pick up my error as pointed out by Martin?

I am using Revit 2016


Have just read through your "Selecting Model Elements" post and think this will give me a better solution than i currently have so will give that a go later today.


Thanks for your help, always appreciated!



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

Post to forums  

Autodesk Customer Advisory Groups

Rail Community