Overview
This guide covers patterns for working with Type 1 (Custom Data) and Type 2 (Simple Model Data) - the simpler data structures you’ll encounter or create in Speckle.Custom Data Patterns
Creating Custom Data
When you control the entire data structure:Nested Custom Structures
Build hierarchies for complex data:Custom Data with Geometry
Combine your structure with geometry:Simple Model Data Patterns
Pattern 1: Properties Dictionary
The most common pattern for simple model data:Properties can be any type (string, number, bool, list). Always use
.get() with defaults for safety.Properties Dictionary vs. Direct Attributes:Use the
properties dictionary when:- Creating data that needs to be queryable by other applications
- Working with metadata that follows BIM/connector conventions
- You want a clear separation between data and structure
- Creating custom application-specific data structures
- Building organizational hierarchies (e.g.,
obj.phases,obj.elements) - You need Python-level attribute access
properties dict is just a convention that makes data more portable and searchable.Pattern 2: Multiple Objects with Properties
Collections of geometry with metadata:Pattern 3: Material References
Simple material system:Pattern 4: Layer Organization
Organize objects by layers:Pattern 5: DisplayValue for Visualization
Add display geometry to custom objects:Always provide
displayValue for custom objects so they’re visible in Speckle viewers, even without native support.Working with Received Simple Data
Extracting Properties
Finding Objects by Property
Extracting Display Geometry
Converting to Common Formats
To Pandas DataFrame
To GeoJSON
Best Practices
Use SDK traversal utilities
Use SDK traversal utilities
The SDK provides built-in traversal utilities - use them instead of writing custom traversal:Benefits: handles edge cases, consistent with SDK patterns, tested and maintained.
Traversal: get_member_names() filters automatically
Traversal: get_member_names() filters automatically
get_member_names() already filters out private members (starting with _) and methods:Always provide properties dictionary
Always provide properties dictionary
Make data queryable by using consistent property names:
Use standard property names
Use standard property names
Follow conventions for common properties:
Include units in property names when needed
Include units in property names when needed
Make units explicit for measurements:
Provide displayValue for custom types
Provide displayValue for custom types
Always include visualization geometry:
Complete Example: Survey Data Pipeline
Summary
Simple data patterns are:- ✅ Easy to create - Direct property access
- ✅ Easy to query - Properties dictionary
- ✅ Self-documenting - Clear structure
- ✅ Portable - No application dependencies
- ✅ Flexible - Add any properties needed
- Custom analysis pipelines
- Simple geometry exports
- Data you control end-to-end
- When you don’t need BIM complexity