# `GSBaseObject`

*Class*

The abstract base class for objects positioned on a layer.

## Declaration

```swift
class GSBaseObject
```

```objc
@interface GSBaseObject : NSObject
```

```python
class GSBaseObject(NSObject)
```

## Overview

`GSBaseObject` provides common ownership, geometry, metadata, change notification, and encoding behavior. Not every inherited operation has the same significance for every subclass; consult the concrete type for its specific contract.

A base object has a weak *parent*, meaning the object that directly contains it. Its *layer* and *glyph* are resolved through this ownership hierarchy and can be `nil` when the object is detached. Attach and detach objects through the collection APIs of their container to keep both sides of the relationship consistent.

Regular editing APIs can register undo and propagate changes through the parent hierarchy, while fast APIs omit that coordination for callers that manage it separately.

## Topics

### Owners

- [`GSBaseObject.parent`](/Core/GlyphsCore/GSBaseObject/parent) — The object that directly contains the receiver, or `nil` when the receiver is detached.
- [`GSBaseObject.layer`](/Core/GlyphsCore/GSBaseObject/layer) — The layer containing the receiver, or `nil` when the receiver is detached from a layer.
- [`GSBaseObject.glyph`](/Core/GlyphsCore/GSBaseObject/glyph) — The glyph containing the receiver, or `nil` when the receiver is detached from a glyph.

### Position

- [`GSBaseObject.position`](/Core/GlyphsCore/GSBaseObject/position) — The position in layer coordinates.
- [`GSBaseObject positionForLayerWidth:`](/Core/GlyphsCore/GSBaseObject/positionForLayerWidth:) — The position in layer coordinates for a layer width.
- [`GSBaseObject setPosition:forLayerWidth:`](/Core/GlyphsCore/GSBaseObject/setPosition:forLayerWidth:) — Sets the position in layer coordinates for a layer width.
- [`GSBaseObject positionFast`](/Core/GlyphsCore/GSBaseObject/positionFast) — The position without orientation adjustment.
- [`GSBaseObject setPositionFast:`](/Core/GlyphsCore/GSBaseObject/setPositionFast:) — Sets the position without registering undo or notifying the parent.
- [`GSBaseObject setPositionFast:grid:`](/Core/GlyphsCore/GSBaseObject/setPositionFast:grid:) — Sets the unrounded position and rounds the position to a grid without registering undo or notifying the parent.
- [`GSBaseObject.positionPrecise`](/Core/GlyphsCore/GSBaseObject/positionPrecise) — The unrounded position in layer coordinates.
- [`GSBaseObject positionPreciseForLayerWidth:`](/Core/GlyphsCore/GSBaseObject/positionPreciseForLayerWidth:) — The unrounded position in layer coordinates for a layer width.
- [`GSBaseObject positionPreciseFast`](/Core/GlyphsCore/GSBaseObject/positionPreciseFast) — The unrounded position without orientation adjustment.
- [`GSBaseObject roundToGrid:`](/Core/GlyphsCore/GSBaseObject/roundToGrid:) — Rounds the position to a grid.
- [`GSBaseObject roundToGridFast:`](/Core/GlyphsCore/GSBaseObject/roundToGridFast:) — Rounds the position to a grid without registering undo or notifying the parent.
- [`GSBaseObject.orientation`](/Core/GlyphsCore/GSBaseObject/orientation) — The orientation of the element position.

### Bounds

- [`GSBaseObject bounds`](/Core/GlyphsCore/GSBaseObject/bounds) — The geometric bounds of the object.
- [`GSBaseObject boundsTransform:`](/Core/GlyphsCore/GSBaseObject/boundsTransform:) — The geometric bounds of the object after applying a transform.
- [`GSBaseObject boundsAngle:`](/Core/GlyphsCore/GSBaseObject/boundsAngle:) — The geometric bounds of the object after applying a transform.
- [`GSBaseObject fastBounds`](/Core/GlyphsCore/GSBaseObject/fastBounds) — The overestimated bounds of the object.
- [`GSBaseObject fastBoundsTransform:`](/Core/GlyphsCore/GSBaseObject/fastBoundsTransform:) — The overestimated bounds of the object after applying a transform.

### Attributes

- [`GSBaseObject.attributes`](/Core/GlyphsCore/GSBaseObject/attributes) — Additional values associated with the object.
- [`GSBaseObject.countOfAttributes`](/Core/GlyphsCore/GSBaseObject/countOfAttributes) — The number of attributes.
- [`GSBaseObject attributeForKey:`](/Core/GlyphsCore/GSBaseObject/attributeForKey:) — The value for an attribute key, or `nil` if no value is set.
- [`GSBaseObject setAttribute:forKey:`](/Core/GlyphsCore/GSBaseObject/setAttribute:forKey:) — Sets or removes an attribute.
- [`GSBaseObject setAttributes:format:`](/Core/GlyphsCore/GSBaseObject/setAttributes:format:) — Replaces all attributes using values encoded for a file format version.
- [`GSBaseObject setAttributesFast:format:`](/Core/GlyphsCore/GSBaseObject/setAttributesFast:format:) — Replaces all attributes without registering undo or notifying the parent.
- [`GSBaseObject removeAttributeForKey:`](/Core/GlyphsCore/GSBaseObject/removeAttributeForKey:) — Removes an attribute.

### Edit Locking

- [`GSBaseObject.locked`](/Core/GlyphsCore/GSBaseObject/locked) — Whether editing operations should leave the object unchanged.

### Temporary Data

- [`GSBaseObject.tempData`](/Core/GlyphsCore/GSBaseObject/tempData) — Values associated with the object for transient use.
- [`GSBaseObject countOfTempData`](/Core/GlyphsCore/GSBaseObject/countOfTempData) — The number of temporary values.
- [`GSBaseObject tempDataForKey:`](/Core/GlyphsCore/GSBaseObject/tempDataForKey:) — The temporary value for a key, or `nil` if no value is set.
- [`GSBaseObject setTempData:forKey:`](/Core/GlyphsCore/GSBaseObject/setTempData:forKey:) — Sets or removes a temporary value.

### Change Tracking

- [`GSBaseObject elementDidChange:`](/Core/GlyphsCore/GSBaseObject/elementDidChange:) — Notifies the parent that an element changed.
- [`GSBaseObject.undoManager`](/Core/GlyphsCore/GSBaseObject/undoManager) — The undo manager provided by the parent, or `nil` when none is available.
- [`GSBaseObject.undoManagerCheck`](/Core/GlyphsCore/GSBaseObject/undoManagerCheck) — The undo manager provided by the parent when undo registration is enabled, or `nil` otherwise.

### Encoding

- [`GSBaseObject propertyListValueFormat:error:`](/Core/GlyphsCore/GSBaseObject/propertyListValueFormat:error:) — A property-list representation in a Glyphs source format, or `nil` when the object cannot be encoded.
- [`GSBaseObject saveToFile:format:context:error:`](/Core/GlyphsCore/GSBaseObject/saveToFile:format:context:error:) — Writes a Glyphs source representation to a file.

### Thread Synchronization

- [`GSBaseObject initLock`](/Core/GlyphsCore/GSBaseObject/initLock) — Prepares the object for synchronized access.

## Relationships

### Inherits From

- `NSObject`

### Inherited By

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

### Conforms To

- [`GSSelectableElementProtocol`](/Core/GlyphsCore/GSSelectableElementProtocol)
- [`GSUserDataProtocol`](/Core/GlyphsCore/GSUserDataProtocol)
- `NSCopying`

