1

Can someone help me understand the difference?

Why does i = 2887 while ii = 3008

FilteredElementCollector groupInstances = new FilteredElementCollector(doc).OfClass(typeof(Group));
FilteredElementCollector groupInstances1 = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_IOSDetailGroups);
FilteredElementCollector groupInstances2 = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_IOSModelGroups);

int i = groupInstances.Count(); // = 2997
int ii = groupInstances1.Count(); // = 3008
int iii = groupInstances2.Count(); // = 155

Possibly answering my own question here, but OST_IOSDetailGroups apears to include GroupTypes in addition to Groups. Of course this lead to another question... Why does Revit expose a method for obtaining Groups, but only detail groups? Why isn't the same functionality available for Model Groups? And ultimately, how do I get started separating the model Groups from the model GroupTypes?

Follow up... This seems to do the trick, but isn't very elegant. I'm sure there is a better way.

try
{
   GroupTypeId = group.GetTypeId().ToString();
} 
catch
{
    GroupTypeId = "GroupType";
}
Skinner
  • 1,461
  • 4
  • 17
  • 27

1 Answers1

0

Almost all Revit categories include the instance elements as well as their types.

The Walls category includes all Wall instances as well as all WallType elements.

The Windows category includes all window family instances as well as all window family symbols.

And so on...

Why do you expect groups to behave differently?

Jeremy Tammik
  • 7,333
  • 2
  • 12
  • 17