ItemFactoryBase.NewGroup Method

ItemFactoryBaseNewGroup Method

Creates a new type of group.

Namespace: Autodesk.Revit.Creation
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
public Group NewGroup(
	ICollection<ElementId> elementIds
)
Public Function NewGroup ( 
	elementIds As ICollection(Of ElementId)
) As Group
public:
Group^ NewGroup(
	ICollection<ElementId^>^ elementIds
)
member NewGroup : 
        elementIds : ICollection<ElementId> -> Group 

Parameters

elementIds  ICollectionElementId
A set of elements which will be made into the new group.

Return Value

Group
A new instance of a group containing the elements specified.
Remarks
  • The new group may contain more members than just the set input to this method. Elements which are closely connected with the inputs (such as sketch and sketch plane) will also be added to the group.
  • Initially the group will have a generic name, such as Group 1. This can be changed by changing the name of the group type as follows: newGroup.GroupType.Name = newName.
  • If a newly-created element is being added to a group, calling document.Regenerate() may be needed to avoid a warning visible in the UI that the group has changed outside group edit mode.
Example
Group group = null;
UIDocument uidoc = new UIDocument(document);
ICollection<ElementId> selectedIds = uidoc.Selection.GetElementIds();

if (selectedIds.Count > 0)
{
    // Group all selected elements
    group = document.Create.NewGroup(selectedIds);

}
Dim group As Group = Nothing
Dim uidoc As New UIDocument(document)
Dim selectedIds As ICollection(Of ElementId) = uidoc.Selection.GetElementIds()

If selectedIds.Count > 0 Then
    ' Group all selected elements

    group = document.Create.NewGroup(selectedIds)
Else

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

See Also