# `GSShapeGroup`

*Class*

A shape group combines zero or more shapes into a single shape, forming a shape tree.

## Declaration

```swift
class GSShapeGroup
```

```objc
@interface GSShapeGroup : GSShape
```

```python
class GSShapeGroup(GSShape)
```

## Overview

- The shapes in the `shapes` array of a group are its **direct members**. Direct members of a group have a relative depth of `1`.
- The **members** of a group are all shapes that the group contains, directly, or more deeply in nested groups. Members of a group have a relative depth greater than or equal to `1`.

## Topics

### Creating a Shape Group

- [`GSShapeGroup initWithId:`](/Core/GlyphsCore/GSShapeGroup/initWithId:) — Creates a new shapes group with a given ID.
- [`GSShapeGroup rootGroupWithParent:`](/Core/GlyphsCore/GSShapeGroup/rootGroupWithParent:) — Creates the root group for a layer.

### Identity

- [`GSShapeGroupID.GSShapeGroupIDRoot`](/Core/GlyphsCore/GSShapeGroup/GSShapeGroupID/GSShapeGroupIDRoot) — The group ID reserved for the root group of a layer.
- [`GSShapeGroup.groupId`](/Core/GlyphsCore/GSShapeGroup/groupId) — The per-layer identifier of the group.
- [`GSShapeGroup.root`](/Core/GlyphsCore/GSShapeGroup/root) — Whether the group is the root of the shape tree.

### Direct Members

- [`GSShapeGroup.shapes`](/Core/GlyphsCore/GSShapeGroup/shapes) — The direct members of the group.

### Membership

- [`GSShapeGroup containsShape:`](/Core/GlyphsCore/GSShapeGroup/containsShape:) — Returns whether the given shape is a member of the group.
- [`GSShapeGroup depthOfShape:`](/Core/GlyphsCore/GSShapeGroup/depthOfShape:) — Returns the relative depth of the shape within the group.
- [`GSShapeGroup groupIndexRange`](/Core/GlyphsCore/GSShapeGroup/groupIndexRange) — The range of layer shape indices that includes all group members and the index of the group shape itself (which is always at the last index of the range).

### Traversal

- [`GSShapeGroup enumerateMembersWithBlock:`](/Core/GlyphsCore/GSShapeGroup/enumerateMembersWithBlock:) — Calls the block with every member of the group, including nested shapes.

### Drawing

- [`GSShapeGroup drawInPen:openPen:supporting:secondaryPen:extraHandles:filter:`](/Core/GlyphsCore/GSShapeGroup/drawInPen:openPen:supporting:secondaryPen:extraHandles:filter:) — Draw a subset of the group into pens.

### Copying

- [`GSShapeGroup deepCopy`](/Core/GlyphsCore/GSShapeGroup/deepCopy) — Creates a copy of the group and all of its members.

### Instance Methods

- [`GSShapeGroup enumerateCompositionUnits:supporting:extraHandles:secondaryPen:`](/Core/GlyphsCore/GSShapeGroup/enumerateCompositionUnits:supporting:extraHandles:secondaryPen:) — Calls the block such that the shapes of the group are divided into composition units ready for display.

## Relationships

### Inherits From

- [`GSShape`](/Core/GlyphsCore/GSShape)

### Conforms To

- [`GSContainerProtocol`](/Core/GlyphsCore/GSContainerProtocol)

## See Also

### Shapes

- [`GSShape`](/Core/GlyphsCore/GSShape) — An abstract base class for graphical elements stored in a glyph layer.
- [`GSPath`](/Core/GlyphsCore/GSPath) — A graphical path made of nodes.
- [`GSComponent`](/Core/GlyphsCore/GSComponent) — A reference to another glyph placed as a shape in a glyph layer.

