Finding Model and Detail Groups

Finding Model and Detail Groups

Anonymous
Not applicable
9,660 Views
3 Replies
Message 1 of 4

Finding Model and Detail Groups

Anonymous
Not applicable

I want to find and manipulate model groups and their attached detail groups.

My first glance at the 2016 SDK didn't find me anything on this - maybe I am missing it.

 

So, what methods are there that will let me:

- Find modelgroup definitions

- Find detail groups that are 'attached' to model groups

- Find 'instances of groups' (i.e. where a group is placed - level, xyz position, rotation, etc)

 

Also, (importantly)

- Given a particular element (e.g. a wall), what group is this part of?

 

 

From a functional point of view, I would like to be able to identify the instances of a group on a level and make sure that their associated detail groups are 'turned on'.

 

Eventually, I would like to build/rebuild groups and associate a detail group with a model group.

For example, identify a set of tags (e.g. by geometry) and great a group out of them, then attach this group to an existing model group.

 

I am a bit surprised that there seems to be almost no discussion of groups in the API world.

Thanks in advance for any help on this.

 

Abba Lustgarten

 

 

 

0 Likes
Accepted solutions (1)
9,661 Views
3 Replies
Replies (3)
Message 2 of 4

BardiaJahan
Advocate
Advocate
Accepted solution

Both ModelGroups and DetailGroups are BuiltinCategories so you can use a FilteredElementCollector with Category filter to retrieve ModelGroups and DetailGroups. Also, the Group class exposes several methods and properties that you might find useful. For example: Location, LevelId, GroupId etc.

 

To get the detail groups attached to model groups or I should say to find which model group it is attached to, you can use BuiltInParameter.GROUP_ATTACHED_PARENT_NAME (Iterate through them and check this parameter on each detail group)

 

I think iterating through groups, gives you the instances of groups not the type (so to speak).

 

To find the corresponding group for each element you should use element.GroupId and if it is Invalid, it means that the element is not in a Group. Something like this:

 


if (element.GroupId.Equals(ElementId.InvalidElementId))
{
message = "The element isn't in any group.";
}
else
{
Autodesk.Revit.DB.Group group = document.GetElement(element.GroupId) as Autodesk.Revit.DB.Group;
}

Message 3 of 4

Anonymous
Not applicable

Thanks for your help.  That definitely points me in the right direction.  I will use this as a basis for a first attempt, and let you know how it goes.

 

Abba

0 Likes
Message 4 of 4

frankholidayjunior
Advocate
Advocate

thanx not often the answer stares u in the face, would be good to seperate the group by its class, is model group or is detail group though.

0 Likes