Get Revit elements


In React, I’m loading the Revit model with the Viewer. When I click on an element, it returns all the Revit properties of that element.

I would need all the data of each element like this after loading the model. Later on, I will need to create an automated selection system using this data.
Can you help to me?

Thank you in advance for your answers!

The viewer provides a tree-like data structure with all the data from the streams it loads:

getDataTree(): DataTree

DataTree provides several methods for working with the tree structure.

type SpeckleObject = Record<string, unknown>
type ObjectPredicate = (guid: string, obj: SpeckleObject) => boolean

interface DataTree {
  findFirst(predicate: ObjectPredicate): SpeckleObject
  findAll(predicate: ObjectPredicate): SpeckleObject[]
  walk(predicate: ObjectPredicate): void
  • SpeckleObject is just the generalization of the speckle objects that come from streams
  • ObjectPredicate is the function type used by the DataTree’s members, and it specifies the internal node’s unique id and the speckle object reference. The returned boolean controls when to stop walking the data tree. A false will terminate the ongoing walk operation

A quick example of usage of the DataTree :

const dataTree = viewer.getDataTree()
// Get all mesh speckle objects
const objects = dataTree.findAll((guid, obj) => {
	return obj.speckle_type === 'Objects.Geometry.Mesh.'

You’re welcome!
However, the retrieved data does not contain all the Revit parameters, only the following ones:

In the example I gave it filters by Mesh objects from you selected object example you see it has speckle_type: Revit.RevitInstance

If you were to see if

const objects = dataTree.findAll((guid, obj) => {
  return obj.hasOwnProperty('parameters');

Only objects with revit Parameters will be returned

1 Like

Thanks for the help! I have the solution!

1 Like