Overview
When working with BIM models in Speckle, you’ll encounter objects whose geometry is represented throughdisplayValue properties. This guide shows you how to extract this geometry, including how to handle instance definitions that require resolving applicationId references.
What you’ll learn:
- How to extract meshes from
displayValueproperties - How to build an applicationId index for reference lookups
- How to resolve InstanceDefinition references to get actual geometry
- How to apply transformations to instances
For a comprehensive explanation of proxies and why Speckle uses them, see BIM Data Patterns: Pattern 5 and Proxification.
The Challenge with Display Values
After receiving a model version withoperations.receive(), objects have a displayValue property containing visualization geometry. This can be:
- Direct meshes - The geometry is right there
- Instance references - References to InstanceDefinition objects by
applicationId
applicationId index to resolve the references.
Extracting Display Values
Finding Objects with Display Values
Start by finding all objects that have display geometry:Extracting Direct Meshes
For objects with direct mesh geometry:Building an applicationId Index
To resolve instance references, build an index mapping applicationIds to objects:Working with Instance Definitions
Understanding Instance Definitions
Instance definitions enable geometry reuse. The definition contains references to geometry objects (by applicationId), and each instance includes a transformation matrix.Extracting Instance Definitions
Extract instance definitions and resolve their geometry references:Resolving Instance References in Display Values
Now you can resolve instance references when extracting display values:Applying Transformations
Instance references include transformation matrices that position, rotate, and scale the geometry:transform is a 4x4 transformation matrix stored as a flat list of 16 numbers (column-major order). This represents position, rotation, and scale.
Complete Example
Here’s a complete workflow combining all concepts:Best Practices
Build the Index Once
Building an applicationId index traverses the entire object tree. Do this once at the start:Use Safe Dictionary Access
Always use.get() when looking up by applicationId:
Check for Proxy Collections
Not all model versions have instance definitions:Troubleshooting
Why can't I find geometry in an instance definition?
Why can't I find geometry in an instance definition?
Problem: Instance definition’s
objects list has applicationIds but you can’t find the geometry.Why this happens: The geometry objects might not have been indexed, or the applicationIds are incorrect.Solution: Verify your index contains the referenced objects:How do I handle mixed display values (meshes + instances)?
How do I handle mixed display values (meshes + instances)?
Problem: Some objects have direct meshes, others have instance references in the same
displayValue list.Why this happens: Complex objects can combine directly modeled geometry with instanced components.Solution: Check the type of each item in displayValue:Why are there no instance definitions in my version?
Why are there no instance definitions in my version?
Problem:
version.instanceDefinitionProxies doesn’t exist or is empty.Why this happens: Not all models use instancing—depends on the source application
and how the model was created.Solution: Always check before accessing, and handle both cases:How do I know if an object uses instances?
How do I know if an object uses instances?
Problem: Can’t tell if displayValue contains meshes or instance references.Why this happens: Both are in the same
displayValue property.Solution: Check for the presence of applicationId:Summary
Key concepts:- ✅ displayValue can contain direct meshes or instance references
- ✅ InstanceDefinition objects reference geometry by
applicationId, not direct embedding - ✅ applicationId index enables fast lookups when resolving references
- ✅ Transformations position, rotate, and scale instanced geometry
- Build applicationId index once
- Extract instance definitions, resolving their geometry references
- Process displayValue, handling both direct meshes and instance references
- Apply transformations where present