# `GSLayer replaceShapeAtIndex:withShape:`

*Instance Method*

Replaces the shape at the given linear shape index.

## Declaration

```swift
func replaceShape(at idx: UInt, with shape: GSShape)
```

```objc
- (void) replaceShapeAtIndex:(NSUInteger) idx withShape:(GSShape *) shape;
```

```python
replaceShapeAtIndex_withShape_(idx: int, shape: GSShape)
```

## Discussion

The new shape receives this layer as its parent and the old shape is detached.

## See Also

### Removing and Replacing Shapes

- [`GSLayer removeShape:`](/Core/GlyphsCore/GSLayer/removeShape:) — Removes a shape from the layer.
- [`GSLayer removeShapes:`](/Core/GlyphsCore/GSLayer/removeShapes:) — Removes shapes from the layer.
- [`GSLayer removeShapesAtIndexes:`](/Core/GlyphsCore/GSLayer/removeShapesAtIndexes:) — Removes the shapes at the given linear shape indexes.
- [`GSLayer removeObjectFromShapesAtIndex:`](/Core/GlyphsCore/GSLayer/removeObjectFromShapesAtIndex:) — Removes the shape at the given linear shape index.

