Skip to main content

The Base Class

Every Speckle object inherits from Base. This is the foundation of Speckle’s object model - it provides identity, serialization, type checking, and dynamic properties.

Core Concepts

1. Static vs Dynamic Properties

Base objects support both typed properties (defined in the class) and dynamic properties (added at runtime):
Why dynamic properties? They let connectors attach application-specific data without defining custom classes. Revit can add parameters, Rhino can add userData, etc.

2. Type Checking

Base performs runtime type checking on typed properties:
Type checking only validates the top-level type. For List[Point], it checks if it’s a list but doesn’t validate each item’s type (for performance).

3. Identity & Hashing

Every Base object has an id - a unique hash of its content:
get_id() serializes the entire object - expensive for large objects! The id property is set during send/receive operations, so use that when available.

4. The speckle_type

Every object has a speckle_type that identifies its class across platforms:
The speckle_type ensures objects are correctly reconstructed when received in other platforms (C#, TypeScript, etc.).

Working with Properties

Setting Properties

Three ways to set properties:

Getting Properties

Validating Property Names

Some property names are invalid:
Properties starting with @ (single) are valid and used for detached references like @displayValue.

Nested Objects

Base objects can contain other Base objects:

Traversing Nested Objects

Creating Custom Objects

You can create custom Base subclasses:
Custom types must have unique speckle_type names. Use a namespace prefix like "MyApp.Wall" to avoid conflicts.

Advanced Features

Chunkable Properties

Large arrays can be chunked for efficient serialization:

Detachable Properties

Large nested objects can be detached and stored separately:
Connectors use detachment for displayValue meshes - keeps the main object lightweight while allowing on-demand mesh loading.

The applicationId

Link objects across sends with applicationId:
Connectors use applicationId to map Speckle objects back to their native application objects (like Revit element IDs).

Common Patterns

Building Collections

Filtering by Type

For BIM Data: In v3, most BIM objects are DataObject instances. To differentiate walls from columns, filter by properties (e.g., properties.category == "Walls") rather than by type. See Data Traversal for property-based filtering patterns.

Copying Objects

Best Practices

Define class properties with types for validation and documentation: python # Good - typed property class Wall(Base): height: float # Less good - dynamic property wall = Base() wall.height = 3.0 # No type checking
Don’t call get_id() repeatedly: python # Bad - serializes every time for obj in objects: if obj.get_id() in seen: continue # Good - use id property or track differently for obj in objects: if obj.id in seen: # Set during send/receive continue
Always set applicationId when creating objects from your application: python from specklepy.objects.geometry import Point # Link to your app's native object point = Point(x=1, y=2, z=3) point.applicationId = f"myapp-{native_object.id}"
When traversing received objects, expect unknown types: python def process_object(obj): if isinstance(obj, Base): # Check speckle_type string instead of isinstance if obj.speckle_type.startswith("Objects.Geometry"): process_geometry(obj) elif hasattr(obj, "displayValue"): process_display_value(obj.displayValue)

Summary

The Base class is powerful because it:
  • Provides identity - Every object has a unique hash
  • Supports dynamic properties - Attach any data without custom classes
  • Type checks typed properties - Catch errors early
  • Works cross-platform - speckle_type ensures interoperability
  • Handles nested objects - Build complex hierarchies naturally
  • Optimizes serialization - Chunking and detachment for large data
Understanding Base is fundamental to working effectively with specklepy!

Next Steps

Data Traversal

Learn how to navigate and extract data from object graphs

Geometry Objects

Explore Points, Lines, Meshes, and other geometry types

Display Values

Understand how geometry is made visible and interoperable
Last modified on July 18, 2026