Most efficient way to count all pipe instances in the project

Most efficient way to count all pipe instances in the project

Maxim-CADman77
Advisor Advisor
364 Views
1 Reply
Message 1 of 2

Most efficient way to count all pipe instances in the project

Maxim-CADman77
Advisor
Advisor

I'd like to know which is the most efficient way to count all pipe instances in the active project.
I'm using C#.

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Accepted solutions (1)
365 Views
1 Reply
Reply (1)
Message 2 of 2

jeremy_tammik
Alumni
Alumni
Accepted solution

Have you looked at the Revit API getting started material at all?

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#2

 

Your question is answered there in full, and many others also.

 

Basically, all you need is a filtered element collector that specifies those pipe instances of interest to you and returns their count. Something like this:

  

  int nPipes = new FilteredElementCollector(doc)
    .OfClass(typeof(Pipe))
    .GetElementCount();

 

For more information, please refer to The Building Coder topic group on filtered element collectors:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.9

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes