$getSharedParamValue
Reads a numeric shared parameter from an object. Returns the value as a number, or null if the parameter is absent or has no value.
Definition
$getSharedParamValue := function($object, $logicalName){
(
$guid := $lookup($paramGuids, $logicalName);
$sp := $guid and $exists($object.values)
? $lookup($object.values, "p_" & $guid)
: undefined;
$exists($sp.value)
? $number($sp.value)
: null
)
};
Dependencies
Requires $paramGuids in the outer scope:
$paramGuids := {
"NLRS_C_weerstandsklasse": "8f1f7e7c-a1c6-46ba-89bf-c28af15d5783"
};
Parameters
| Parameter | Type | Description |
|---|---|---|
$object |
object | The element to read from (pass $ for current element) |
$logicalName |
string | The key in $paramGuids |
Return value
| Situation | Returns |
|---|---|
| Parameter exists with value | 3 (number) |
| Parameter exists, no value | null |
| Parameter absent | null |
Why $number() is used
Revit may store numeric parameter values as strings. $number() ensures the output field is a proper JSON number, which matters when the validator uses int:LessThan, int:GreaterThan, or int:EqualTo.
Usage
$[type = "FamilyInstance" and $exists(parent)].{
"id": id,
"name": name,
"NLRS_C_weerstandsklasse": $getSharedParamValue($, "NLRS_C_weerstandsklasse")
}
Validator: NLRS_C_weerstandsklasse → list:IsIn [1, 2, 3, 4, 5, 6]
Used in rules
rule-b5262621— NLRS_C_weerstandsklasse is een geldige waarde