How to access all the family types through revit API?

孤者浪人 提交于 2021-02-08 04:12:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!