问题
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!
回答1:
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.
回答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.
回答3:
Ok sorry. Obviously I was wrong, it does point to all Elements, including the ones that are not instantiated.
来源:https://stackoverflow.com/questions/44067771/how-to-access-all-the-family-types-through-revit-api