2

Is it possible to access all the family types of a certain category (e.g. Windows, Doors, ...) with Revit API? In contrast with the instances. For what I know, using FilteredElementCollector(doc).OfCategory(...).ToElements() or FilteredElementCollector(doc).OfClass(...).ToElements() point to the instances of that class/type, but I want to check if a particular type is already loaded within Revit, even if it hasn't been instantiated yet.

(I'm using pyRevit, Revit 2017)

Thanks a lot!

Arnaud
  • 445
  • 4
  • 18

3 Answers3

2

In your filteredElementCollector, before you do ToElements(), you should add WhereElementIsElementType(), then the ToElements().

For Family based elements like doors, you'll get back FamilySymbol elements - from there you can check if they're active.

Matt
  • 1,043
  • 5
  • 8
2

I believe the easiest approach to determine all families that have been instantiated is to retrieve all family instances.

From the instances, you can determine the family symbol and the family itself, and be certain that it has been instantiated.

If there is no instance, you will get no family or family symbol entry.

Oh, on re-reading, I see that you want the opposite, a list of all families regardless of whether they have been instantiated or not. Oh no, a list of all family symbols of a specific category, regardless of whether they have been instantiated or not.

That is in fact already demonstrated by one of the numerous filtered element collector snippets in The Building Coder samples CmdCollectorPerformance module:

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/CmdCollectorPerformance.cs#L294-L332

To be precise, the method GetFamiliesOfCategory implemented there retrieves all families of a given category. You can easily adapt that to retrieve the family symbols instead.

Jeremy Tammik
  • 7,333
  • 2
  • 12
  • 17
  • Thank you Jeremy! – Arnaud May 22 '17 at 07:26
  • A question though: in your "GetFamiliesOfCategory" function, you use a filtered element collector, then OfClass "Family". If I do that in my project, and let's say, loop over it and print the FamilyCategory.Name, it seems that it only print the instantiated elements. Because, for instance, it doesn't print any 'Ducts', 'Ducts System', etc... that indeed aren't instantiated in my project. I'm not used to C# and thus maybe I miss something in my interpretation of your code? Thanks! – Arnaud May 22 '17 at 12:22
0

Ok sorry. Obviously I was wrong, it does point to all Elements, including the ones that are not instantiated.

Arnaud
  • 445
  • 4
  • 18