Double post here
I hate when people do this, but for this one time…
I have 4 different functions that fetch:
-
model group instances count
-
model group types count
-
detail groups instances count
and you guessed it…
- detail groups types count
for model group instances, I go with:
model_groups_instances_ids = (
DB.FilteredElementCollector(doc)
.OfCategory(DB.BuiltInCategory.OST_IOSModelGroups)
.WhereElementIsNotElementType()
.ToElementIds()
)
arrays_groups_ids = [array.IntegerValue for array in q.get_array_group_ids(doc)]
return len([model_group_id for model_group_id in model_groups_instances_ids if model_group_id.IntegerValue not in arrays_groups_ids])
where get_array_group_ids is:
def get_array_group_ids(doc=None):
"""
Collects and returns the IDs of all array groups in the given document.
Args:
document (DB.Document): The Revit document to search for array groups.
Returns:
list: A list of element IDs representing the array groups.
"""
array_list = DB.FilteredElementCollector(doc or DOCS.doc).OfCategory(
DB.BuiltInCategory.OST_IOSArrays
)
arrays_groups = []
for ar in array_list:
arrays_groups.extend(ar.GetOriginalMemberIds())
arrays_groups.extend(ar.GetCopiedMemberIds())
return set(arrays_groups)
The count is right in a very simple example file containing arrays I made and groups I made.
In the latest Revit arch sample (2024), for example, the count if off… and I don’t get why…
Any pointer appreciated; I spent way too much time on this already.