Rooms
Rooms are spatial elements that represent enclosed areas in a Revit model. They carry area, level, number, and name data, and are commonly used for space validation rules.
The Room object
{
"id": 312045,
"type": "Room",
"name": "Office",
"parent": null,
"values": {
"number": "1.01",
"level": "01 eerste verdieping",
"area": 24.5
}
}
Key fields:
| Field | Description |
|---|---|
values.number |
Room number — used for identification and uniqueness checks |
name |
Room name — the display name |
values.level |
Level name as a string |
values.area |
Calculated area |
Basic filter
$[type = "Room"].{
"id": id,
"type": type,
"name": name,
"number": values.number,
"level": values.level
}
Detecting duplicate room numbers
A common rule checks that no two rooms share the same number. This requires comparing each room against the rest of the dataset.
(
$rooms := $[type = "Room"];
$countDuplicates := function($number, $id) {
$count($rooms[values.number = $number and id != $id])
};
$rooms.{
"id": id,
"type": type,
"name": name,
"number": values.number,
"duplicateCount": $countDuplicates(values.number, id)
}
)
Each room gets a duplicateCount field. The validator then checks that duplicateCount = 0.
Note: this pattern uses a function that queries the full $rooms array from its outer scope. The function variable captures $rooms at definition time.
Checking room number prefix against level prefix
A rule can verify that a room number starts with the correct prefix for its level — for example, room 1.01 should be on a level whose name starts with 1.
$[type = "Room"].(
$roomPrefix := $split(values.number, ".")[0];
$levelPrefix := $split(values.level, " ")[0];
{
"id": id,
"name": name,
"number": values.number,
"level": values.level,
"prefixMatch": $roomPrefix = $levelPrefix
}
)
The validator then checks prefixMatch = true.
Common mistakes
- Filtering
type = "FamilyInstance"instead oftype = "Room"— Rooms are their own object type - Using
namefor uniqueness instead ofvalues.number— names can be duplicated intentionally - Expecting
values.levelto be a levelid— it is a string (the level name)