---
title: BVL
summary: The BIM.works Visualisation Language — if/else blocks over BQL conditions, groups, the action vocabulary (show, hide, colour, select, labels, annotations, section and fade behaviour), subjects, and where BVL runs.
order: 20
terms: [bql, action]
see-also: [reference/bql/where, reference/bcl, reference/bsl, how-to/using-bimworks/use-the-actions-tree]
---

# BVL

BVL describes what the viewer shows: which objects are visible, selected or coloured, which carry labels and annotations, how section planes and the proximity fade treat them. It changes the picture only, never the model, and it re-runs freely. A BVL script is a chain of `if` blocks whose conditions are BQL boolean expressions; the grammar builds on BQL and inherits every feature and comparator of it ([[bvl:grammar]]).

## Where it runs {#where}

- **Actions tree** — a *Visualisation* action (type `BVL`) stores a script and runs it on the loaded models from the Actions panel ([[page:how-to/using-bimworks/use-the-actions-tree]]); the chat proposes the same kind of action.
- **Checks and reports** — a [[page:reference/bcl|BCL]] block may contain BVL action sets to colour its scope and results; a [[page:reference/brl|BRL]] viewport takes a `style:` with BVL to restyle what it renders.
- **Sequences** — a [[page:reference/bsl|BSL]] sequence is a list of BVL frames.
- **Drawings and tiles** — the vector export (`ExportVectorSvg`) takes a `bvl` and draws its colours and its `label()` / `annotate(text())` / `annotate(template())` rows as text at the objects ([[page:how-to/rendering/export-a-vector-drawing]]); the 3D Tiles export takes the same `bvl` in its settings and writes `label("key", …)` rows as batch-table columns.
- **API** — [[openapi:ResolveBvl]] takes `models`, the script as `bvl` and optional `parameters`, and returns the resolved actions: the sets of qids to show, hide, select and colour, the labels, annotations and virtual geometry, ready for the viewer. The SDKs call the `ResolveBvl` task behind it, whose script field is `input` (text or the [[bql:ast|AST]] form) or `query_uuid` (a stored *Visualization* action you may read). A script applies to the objects with geometry, the ones a viewer can draw: an `else { HIDE; }` does not list every product without geometry. Pass `include_non_geometric: true` to apply it to those products too; `model_coverage` in the answer counts them either way. The Java SDK exposes it as `client.bim.resolveBvl(input, versionUuids)`; the viewer package's `BvlHelper` (`@bimworks/viewercommon`) resolves a script and applies it to an `ObjectStateManager`. `ParseBvl` returns the tree of a script.

## Structure {#structure}

```text {#bvl-structure}
if (<condition>) { <content> } [else if (<condition>) { <content> }] [else { <content> }]
<content> := group (<feature>) { <content> } ...   // groups first
             <action> [<action> ...] [<subject>];  // then action sets
             if (...) { ... } ...                  // then nested ifs
```

The condition is a BQL boolean expression without `WHERE` ([[bql:where]]); it may also carry `GROUP BY`, `ORDER BY`, `LIMIT` and `OFFSET`, which lets a block address the top *n* of a sort. Inside a block the order is fixed: `group` blocks, then action sets, then nested `if` blocks. An action set is one or more actions followed by `;` — `SHOW SELECT;` is one set of two actions. Nested `if` blocks apply within the objects matched by the enclosing one; `else` takes the rest.

```bvl {#bvl-if-else}
if (type = IFCWALL AND property.Pset_WallCommon.IsExternal = true) {
    COLOR "#800080";
} else if (type = IFCWALL) {
    COLOR "#cccccc" 50%;
} else {
    HIDE;
}
```

```bvl {#bvl-top-n}
if (type = IFCWALL ORDER BY aabb.height DESC LIMIT 3) { COLOR "red" SELECT VIEWFIT; }
```

## Groups {#groups}

`group (<feature>) { ... }` runs its block once per distinct value of the feature among the matched objects; `COLOR auto` inside it gives every value its own colour, which is what the legend in the viewer shows.

```bvl {#bvl-group}
if (type = IFCSPACE) { group (property.Pset_SpaceCommon.Category) { COLOR auto 30%; } }
```

## Color by volume measurement quality {#volume-quality}

This styles all loaded models by the calculation quality of `netVolume` (material volume). Green is analytic, blue is bounded, orange is an unbounded estimate, and grey is unavailable or not calculated. The categories describe the method; they do not imply that the maximum error meets its cutoff. Use `volume` in place of `netVolume` to inspect the older raw mesh volume, which currently has no maximum-error certificate. Rebuild existing FeatureDb databases to populate the quality index.

```bvl
SHOW;
if (calculated.quantity.netVolume.quality = "analytic") {
    COLOR "#2E7D32";
} else if (calculated.quantity.netVolume.quality = "bounded") {
    COLOR "#1565C0";
} else if (calculated.quantity.netVolume.quality = "unboundedEstimate") {
    COLOR "#EF6C00";
} else {
    COLOR "#9E9E9E";
}
```

[Download the BVL example](../../examples/bvl/volume-quality.bvl). See [[page:reference/bql/calculated-values#measurement|Measurement quality and accuracy]] for the stored metadata.

## Actions {#actions}

| Action | Effect |
|---|---|
| `SHOW`, `HIDE` | Visibility. |
| `COLOR "<name or #hex>" [<n>%]` | Override colour, optional transparency in percent. Colours are always quoted. |
| `COLOR auto [<n>%]` | Distinct automatic colours (the keyword, not a string). |
| `COLOR RESET [<n>%]` | Restore the original colours, optionally with transparency. |
| `WIREFRAME SHOW`, `WIREFRAME HIDE` | Override object edge visibility independently of faces. `SHOW` can draw edges of hidden objects. The global wireframe rendering mode still applies. |
| `WIREFRAME RESET` | Restore edges following object visibility (the default). |
| `WIREFRAME COLOR "<name or #hex>" [<n>%]` | Override the object's wireframe colour, optionally with transparency. |
| `WIREFRAME COLOR RESET` | Restore the viewer's fixed wireframe colour (the default). |
| `SELECT`, `UNSELECT` | Selection. |
| `VIEWFIT [<duration>] [FROM "<side>"] [MARGIN <n>%]` | Move the camera to fit the matched objects: in the given time (`1500ms`, `2s`), looking from a side (`"top"`, `"bottom"`, `"front"`, `"back"`, `"left"`, `"right"`), with a margin around them ([animated](#transition)). |
| `PICKABLE`, `UNPICKABLE` | Whether clicks hit the objects. Using either switches the viewer's pickability on for this result, until the next result is shown. |
| `SECTIONABLE`, `UNSECTIONABLE` | Whether section planes cut them. |
| `ENDCAPS`, `NO_ENDCAPS` | Filled caps on section cuts. |
| `SOFT_OCCLUDER`, `NO_SOFT_OCCLUDER` | Register as soft occluders for the camera-proximity fade: they dither out and become click-through as the camera approaches. Argument-free; the fade distances are a viewer setting ([[page:how-to/viewer3d/proximity-fade]]). |
| `ON_TOP`, `NOT_ON_TOP` | Draw the objects in front of everything else, so they stay visible (and are clicked first) behind walls. Among each other they keep their depth order. Until the next result is shown. |
| `label(...)` | A text at the object ([labels](#labels)). |
| `annotate(...)`, `clearAnnotations(...)` | Pinned annotations ([annotations](#annotations)). |

```bvl {#bvl-actions}
if (type IN (IFCWALL, IFCSLAB, IFCROOF)) { SOFT_OCCLUDER; }
if (type = IFCFURNISHINGELEMENT) { COLOR "gray" 70% UNPICKABLE; }
if (type = IFCSPACE) { HIDE; }
if (type = IFCDOOR) { ON_TOP; }
```

Wireframes use the viewer's fixed colour and follow object visibility unless overridden. Wireframe overrides are cleared when the next BVL result is shown or the view is reset. They style object edges in the interactive 3D viewer; selection and x-ray outlines keep their own appearance.

```bvl {#bvl-wireframes}
if (type = IFCSPACE) { HIDE WIREFRAME SHOW WIREFRAME COLOR "#3070b3"; }
if (type = IFCWALL) { WIREFRAME HIDE; }
```

The public `Viewer3d` API exposes `setWireframeVisibility(qids, true | false | null)`, `setWireframeColor(qids, "#3070b3" | null)` and `resetWireframes(qids?)`. A `null` visibility restores following the object; a `null` colour restores the fixed default. Omitting `qids` in `resetWireframes()` resets all objects.

## Animated results {#transition}

A script that starts with `TRANSITION <duration> ["<easing>"];` shows its result animated from what the viewer shows: hidden objects fade out, shown ones fade in, colours and transparency blend, the selection highlight fades, and `VIEWFIT` flies the camera. The duration is a number followed by `ms` or `s`; the easing is `"linear"`, `"ease-in"`, `"ease-out"` or `"ease-in-out"` (the default). Without the header a result appears at once, as it always has.

```bvl {#bvl-transition}
TRANSITION 600ms;
if (type = IFCDOOR) { SHOW COLOR "orange" SELECT; } else { HIDE; }
```

`VIEWFIT` takes its own time, so the camera can fly longer than the objects fade; all objects of a script's `VIEWFIT`s are fitted together, with the options of the last one that gives any.

```bvl {#bvl-viewfit-options}
TRANSITION 500ms "ease-out";
if (attribute.Name = "D-012") { SHOW SELECT VIEWFIT 1500ms FROM "front" MARGIN 20%; }
```

Only the visibility, the selection, the colours and the camera animate; labels, annotations, wireframes and the object flags (pickable, on top, section and fade behaviour) change at once. The 3D viewer on WebGPU (Viewer3D-Next) animates; on WebGL the result appears at once, the camera flying as `VIEWFIT` always did. `ResolveBvl` returns the header as `transition` and the options as `viewFitOptions`; `BvlHelper.processResults` turns them into one `ObjectStateManager.transition` step.

## Labels {#labels}

`label(<value>[, HOVER | ANNOTATION])` shows a text at the object. The value is a `"string"` or a feature, as `"prefix " + feature + " postfix"` with the prefix and postfix optional. Where the feature goes, any arithmetic of a GET column may go too ([[bql:get#arithmetic]], [[bql:functions#numbers]]), followed by an optional `UNIT` to show it in ([[bql:unit]]): `quantity.*.NetVolume - calculated.quantity.netVolume UNIT dm3`. A `+` before a `"string"` starts the postfix, never an addition. Without a `UNIT` a value with a unit shows in its system unit (m, m², m³) and a plain number with all its digits, so round a ratio with `ROUND(…, 0.1)`; an object on which an operand has no value shows no value. `HOVER` makes it one of the object's labels, which the 2D viewer and the 3D viewer's plans (2D mode) write inside the object where the text fits ([[page:how-to/viewer3d/show-a-floor-plan#room-labels]]); the 3D view shows them nowhere else. `ANNOTATION` pins it in every view. `SEQ` is a running number, `image("<url>")` an image. Several `label()` actions in one action set give the object several rows, in script order — three rows for a space are three labels; a key (`label("Area", calculated.quantity.floorArea)`) is shown as `Area: 12.35 m²`. A vector drawing draws every row and keeps the kind as a CSS class.

```bvl {#bvl-label}
if (type = IFCDOOR) { label("Door " + attribute.Name, HOVER); }
if (type = IFCSPACE) { label(attribute.Name) label(attribute.LongName) label("Area", calculated.quantity.floorArea); }
if (type = IFCWALL) { label("Off by", quantity.BaseQuantities.NetVolume - calculated.quantity.netVolume UNIT dm3); }
```

## Annotations {#annotations}

`annotate(<representation> [always | link | hover] [distance <length>] [nearest <n>] [occlusion hide | dim | none] [cluster on | off] [scale distance | fixed] [anchor <point>] [align center | above | below | left | right] ["<group>"])` pins an annotation to the object. The representation is `text("...")` (optionally with a key and colours), `svg("<url>")` or `image("<url>")`; the visibility mode, a view-distance limit, a count limit, the occlusion mode, the cluster mode, the scale mode, the anchor, the align and a group name are optional and go in any order after the representation, each at most once: `annotate(text("Inspect") "maintenance" hover)` is `annotate(text("Inspect") hover "maintenance")`, and a second `hover` or `nearest` is an error. The count limit `nearest <n>` makes the 3D viewer show at most n annotations of the group, those nearest to the camera, which changes as the camera moves; annotations hidden behind other geometry take no place, and hovering an object still shows its annotation. Without a group name each `annotate` forms a group of its own. The viewer's "Show only the nearest annotations" setting limits all annotations together on top of this. The occlusion mode says what the 3D viewer does while the object is behind other geometry: `hide` removes the annotation (the default), `dim` draws it faded, `none` keeps showing it. The cluster mode says whether the 3D viewer may merge the annotation with nearby ones into one marker with a count: `on` (the default) or `off`, which always shows it at its own place. Only `svg` icons and `text` labels cluster; images never do. The scale mode says how the 3D viewer sizes the annotation: `distance` draws it smaller the further it is from the camera, at its normal size up to 10 m and down to 40 % of it, never larger, and at its normal size again while it or its object is hovered; `fixed` keeps its normal size at any distance. Without a scale mode the viewer's "Shrink distant annotations" setting decides. Text annotations shown as dots keep their size. The anchor says where on the object the annotation sits: a point of the object's box in its model's own axes, the same for everyone and from every view. It is `center` (the default) or up to three words in this order: `top` or `bottom` (the model's +Z or −Z), `front` or `back` (−Y or +Y) and `left` or `right` (−X or +X); an axis left out is the middle. So `top` is the middle of the top face, `top back left` a corner of it and `left` the middle of the left face. The model opens in 3D seen from the front, and its plan has the back at the top: `top back left` is then the top left corner of a room in the plan and the far left corner of its ceiling in 3D. Seen from elsewhere the point stays where it is, so a `back` label is at the back when you look from behind. The align says which side of that point the annotation is drawn on, on screen: `center` on it, or `above`, `below`, `left` or `right` of it, so that a label on a corner stands beside the object instead of across its edge. Without an align text and icons are centred on their point. In a vector drawing an anchor that does not fall on the object's centre line in that view (a corner in a plan, `top` in an elevation) puts that annotate's rows in a block of their own at that point. `clearAnnotations(all)` or `clearAnnotations("group", ...)` removes them.

```bvl {#bvl-annotate}
if (type = IFCPUMP) { annotate(text("Inspect") hover distance 20 m scale distance "maintenance") VIEWFIT; }
if (type = IFCFIRESUPPRESSIONTERMINAL) { annotate(svg("glyphicons-basic-23-fire.svg") nearest 50 occlusion dim cluster off "safety"); }
if (type = IFCSPACE) { SHOW annotate(text(attribute.GlobalId) anchor top back left align right "GlobalIds"); }
if (type = IFCPUMP AND property.*.Status = "OK") { clearAnnotations("maintenance"); }
```

### Templates {#annotation-templates}

`annotate(template("<name>"[, "<field>" = <value>]...) ... [expand hover | click | none] [anchor <point>] [align ...] ["<group>"])` draws the annotation with a template the 3D viewer has registered: a styled card with the object's data instead of a line of text. A value is what `label()` and `text()` take: a feature or an expression ([labels](#labels)), a `"string"` or `SEQ`; it is evaluated per object, and a feature without a value leaves the field out. Field names are strings. Several `annotate(template(...))` of the same template and group on one object make one annotation, a later field of the same name winning. The other modifiers mean what they mean for `text()`; `expand` says when the larger card shows (on hover, on a click, never); it is for templates only, and on `text`, `svg` or `image` it is ignored with a warning. Without an `anchor` a template sits where it was designed to: `objectLabel` and `asset` on top, `roomTag` on the floor, the others in the centre; without an `align`, by the template's own origin (a pin's tip for most).

| Template | Draws | Fields it reads itself |
|---|---|---|
| `objectLabel` | the name in bold, the long name and the object type | `name`, `longName`, `objectType` |
| `properties` | the name and a row per field: any field names, the bindings are the rows | `name` |
| `roomTag` | number, name and floor area of a space | `name`, `longName`, `area` (`quantity.*.NetFloorArea`) |
| `checkResult` | one rule's outcome: `check`, `rule`, `outcome` (`pass`, `warn`, `fail`), `expected`, `actual` | `object` |
| `quantityCheck` | the card of the [[page:demos/quantity-check|quantity check]]: the value in the model against the calculated one and their difference, `quantity` (its name), `specified`, `calculated` (in the same `UNIT`, or there is no difference), and the verdict from a `tolerance` in percent, as `!= … WITHIN` judges, or the `outcome` (`differs`, `agrees`, `na`) | `name`, `type`, `storey` |

A built-in template reads its own fields; a binding of the same name replaces one. `issue`, `conversation`, `sensor`, `bcfTopic`, `asset` and `progress` take their data from the application, not from BVL, and an unknown bare name is an error. An application can register templates of its own under a dotted name (`acme.fireRating`); BVL names them like built-ins and binds their fields, and the viewer fetches the fields the script leaves out. A viewer that does not know the name shows the fields as text. The vector export draws a template annotation as text rows: the name and other leading fields of a built-in, every field as `key: value` for `properties` and an application's template; the 3D Tiles export leaves template annotations out.

```bvl {#bvl-annotate-template}
if (type = IFCDOOR) { annotate(template("objectLabel") anchor top "doors"); }
if (type = IFCSPACE) { annotate(template("roomTag", "area" = calculated.quantity.floorArea) scale distance anchor bottom "rooms"); }
if (type = IFCWALL) { annotate(template("properties", "Fire rating" = property.*.FireRating, "Area" = quantity.*.NetSideArea) expand hover "walls"); }
if (type = IFCDOOR AND property.Pset_DoorCommon.FireRating = null) { annotate(template("checkResult", "rule" = "FireRating is present", "outcome" = "fail") occlusion dim expand click); }
if (type = IFCWALL) { annotate(template("quantityCheck", "quantity" = "Net volume", "specified" = quantity.BaseQuantities.NetVolume UNIT m3, "calculated" = calculated.quantity.netVolume UNIT m3, "tolerance" = "1 %") "net volume"); }
```

## Subjects {#subjects}

An action set may end with a subject: a virtual shape (`BOX`, `CYLINDER`, `CONE`, `SPHERE` of [[bql:spatial-and-advanced#virtual]]), `MAXIMUM_INSCRIBED_CYLINDER(...)`, `CLASHES_WITH(...)`, `geometry`, or `PATH(<targets>[, THROUGH(...)][, AGENT(...)])`. The actions then apply to that geometry instead of the object: `COLOR` with a subject draws the shape in the colour, `PATH` draws the walkable route to the nearest target as a polyline.

```bvl {#bvl-subject}
if (type = IFCSPACE) { COLOR "#3070b3" 40% MAXIMUM_INSCRIBED_CYLINDER(geometry3d, 2.1 m); }
```

## Parameters {#parameters}

`$name` in a condition is bound at run time exactly as in BQL ([[bql:using#parameters]]); `ResolveBvl` takes the same `parameters` object.

```bvl {#bvl-parameter}
if (qid IN $selection) { COLOR "orange" SELECT; } else { COLOR RESET 70%; }
```

## Common mistakes {#mistakes}

- A missing `;` after an action set.
- `COLOR #800080` — colours are strings: `COLOR "#800080"`.
- `COLOR "auto"` or `COLOR "RESET"` — keywords, not strings.
- Action sets before `group` blocks, or `if` blocks before action sets — the order inside a block is fixed.
- Conditions on `*TYPE` classes select nothing visible ([[bql:types#occurrences]]).

## Used in {#used-in}

- [[page:how-to/using-bimworks/use-the-actions-tree]] — storing and running a visualisation.
- [[page:reference/bcl#actions]] — BVL inside a check.
- [[page:reference/brl#viewports]] — BVL as viewport style.
