# `GSLayer createShapeGroupFromShapes:`

*Instance Method*

Combines the given shapes into a new shape group.

## Declaration

```swift
func createShapeGroup(from memberCandidates: [GSShape]) -> GSShapeGroup?
```

```objc
- (GSShapeGroup *) createShapeGroupFromShapes:(NSArray<GSShape *> *) memberCandidates;
```

```python
createShapeGroupFromShapes_(memberCandidates: list[GSShape]) -> GSShapeGroup
```

## Return Value

The newly created shape group. `nil` is returned if one of the given shapes is not part of the layer’s shapes or the given shapes array is empty.

## Discussion

The newly created shape group is placed in the layer’s shape group tree where the topmost shape in `memberCandidates` is located.

Any shape groups in `memberCandidates` are moved together with all their members into the new shape group. Therefore, for any shape group in `memberCandidates`, it is not necessary to include any of its members in `memberCandidates`, but their inclusion is allowed.

The new shape group contains the given shapes in the same relative order as they appear in the layer’s `shapes` array.

## See Also

### Moving Shapes in Groups

- [`GSLayer handleShapesFromShapes:`](/Core/GlyphsCore/GSLayer/handleShapesFromShapes:) — Returns `subjects` reordered such that the relative order is the same as in `shapes`, excluding any shapes in `subjects` that are members of a shape group in `subjects`.
- [`GSLayer moveShapes:copyBuffer:intoGroup:childIndex:`](/Core/GlyphsCore/GSLayer/moveShapes:copyBuffer:intoGroup:childIndex:) — Moves or copies the given shapes to a new location in the layer’s shape group tree.
- [`GSLayer dissolveShapeGroup:`](/Core/GlyphsCore/GSLayer/dissolveShapeGroup:) — Dissolves the given shape group by replacing it with its direct members.

