Understanding the Structure of the Record Object
Before extracting the parameters, let's examine the structure of the record object in the received data. The record object consists of key-value pairs, where each field represents a specific attribute of the element. In this case, “parameters” field contains all the parameters related to the object, stored as another record object. It's important to understand this nested structure to effectively extract the desired parameter information.
Extracting Parameters Record
Parameters record contains all the parameters about an object. To extract the parameters record, we will use the Power Query Editor in Power BI. Open the Power Query Editor by clicking on "Transform Data" in the Power BI toolbar.
Method 1: Expanding the Record Column
One way to extract parameters is by expanding the record column. However, this method replaces the existing data column, limiting our access to other data. To expand the record column:
- Click on the expand record icon and select the parameters field.
- Choose whether to use the original column name as a prefix.
- Click OK.
Although this method is available, we recommend the next approach for better flexibility.
Method 2: Adding a New Column for Parameters
Instead of expanding the existing column, we can add a new column to extract the parameters.
- In the Power Query Editor, click on "Add Column".
- Select "Custom Column."
- Provide a name for the column (e.g., "params") and specify the formula. You can access the parameters using the "data" field and then navigate to the "parameters" field within it. In this case the formula will be:
- Click “OK” to add the new column.
Extracting Values from Parameter Objects
Revit parameters are stored as record objects due to the complexity and flexibility of the parameter system in Revit. To access specific parameter values, you can use additional custom transformations or built-in Power Query functions, such as navigating through nested fields and extracting values based on specific keys.
Method 1: Extracting Values using Lookup Function
You can access the values for specific parameters by navigating through the nested fields. For example, if you want to extract the value of “Area” parameter from the “parameters” record, you can do the following formula:
Method 2: Using ToNameValueRecord Function
We recently added ToNameValueRecord function in the Speckle namespace to make interactions with Revit parameters much simpler. This function simplifies the extraction and transformation of parameter data by converting the complex parameter records into a more accessible format.
This function lives under:
It accepts a
Record object and returns the Transformed Record as the output.
In this case, we added a new column for transformed version of the parameters record. Here is the formula used:
paramsrepresents the parameters record extracted in the previous step.
Here is the parameters record before transformation:
Here is after:
As you can see, this function streamlines the process of working with Revit parameters, making it more efficient and user-friendly.
In this tutorial, we showed you how to extract parameter values from received Revit data. We learned how to work with the received data and its structure. We also shared alternative approaches you can take to extract the parameter values.
If you have any questions, feel free to ask them at speckle.community.
Try this tutorial, let us know what you think!