# Working with groups

Creation and editing groups of subshapes of a geometrical object makes handling subshapes much easier. This functionality is available in OCC viewer only.

Create a group

To create a group of subshapes of a geometrical object in the main menu select New entity > Group > Create.

The following menu will appear.

In this Menu:

- Shape Type radio button define the type of elements for the group (points, lines, planes or shapes).

- Group Name - here you can enter the name of the group, by default, it is Group_n.

- Then, using the button, select the Main Shape (a geometrical object on which the group will be created). You can select the elements of your group in two ways:

- Clicking Select Sub-Shapes button you can select them manually in the 3D Viewer, and add to the group by clicking the Add button (keep down the Shift button on the keyboard to select several elements and add all them together). The indexes of the selected elements will be displayed in the list. To delete elements from the list, select them and click Remove button.

- Clicking Select All button you can add all object's elements of a certain type in the list of the elements of the group. To delete elements from the list, select them and click Remove button.

- Finally, confirm your selection by clicking OK (also closes the Menu) or Apply (leaves the Menu open for creation of other groups), or skip it by clicking Close button.

The Result of the operation will be a GEOM_Object.

TUI Command: geompy.CreateGroup(MainShape, ShapeType), where MainShape is a shape for which the group is created, ShapeType is a type of shapes in the created group.

Arguments: 1 Shape + Type of subshape.

Example:

Edit a group

To Edit an existing group in the main menu select New entity > Group > Edit. This menu is designed in the same way as the Create a group menu.

The Result of the operation will be a GEOM_Object.

TUI Command:

- geompy.AddObject(Group, SubShapeID), where Group is a group to which a sub shape has to be added, SubShapeID is an ID of the sub shape to be added to the group

- geompy.RemoveObject(Group, SubShapeID), where Group is a group from which a sub shape has to be removed, SubShapeID is an ID of the sub shape to be removed from the group

- geompy.GetObjectIDs(Group), where Group is a group for which its object ID’s are returned.

Returns: List of IDs.

Arguments: 1 Shape + its subshapes.

Dialog Box:

Our TUI Scripts provide you with useful examples of Working with Groups.