BVL
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.
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#
- Actions tree — a Visualisation action (type
BVL) stores a script and runs it on the loaded models from the Actions panel (Use the Actions tree); the chat proposes the same kind of action. - Checks and reports — a BCL block may contain BVL action sets to colour its scope and results; a BRL viewport takes a
style:with BVL to restyle what it renders. - Sequences — a BSL sequence is a list of BVL frames.
- Drawings and tiles — the vector export (
ExportVectorSvg) takes abvland draws its colours and itslabel()/annotate(text())/annotate(template())rows as text at the objects (Export a vector drawing); the 3D Tiles export takes the samebvlin its settings and writeslabel("key", …)rows as batch-table columns. - API — ResolveBvl takes
models, the script asbvland optionalparameters, 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 theResolveBvltask behind it, whose script field isinput(text or the AST form) orquery_uuid(a stored Visualization action you may read). A script applies to the objects with geometry, the ones a viewer can draw: anelse { HIDE; }does not list every product without geometry. Passinclude_non_geometric: trueto apply it to those products too;model_coveragein the answer counts them either way. The Java SDK exposes it asclient.bim.resolveBvl(input, versionUuids); the viewer package'sBvlHelper(@bimworks/viewercommon) resolves a script and applies it to anObjectStateManager.ParseBvlreturns the tree of a script.
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 ifsThe condition is a BQL boolean expression without WHERE (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.
if (type = IFCWALL AND property.Pset_WallCommon.IsExternal = true) {
COLOR "#800080";
} else if (type = IFCWALL) {
COLOR "#cccccc" 50%;
} else {
HIDE;
}if (type = IFCWALL ORDER BY aabb.height DESC LIMIT 3) { COLOR "red" SELECT VIEWFIT; }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.
if (type = IFCSPACE) { group (property.Pset_SpaceCommon.Category) { COLOR auto 30%; } }Color by volume measurement 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.
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. See Measurement quality and accuracy for the stored metadata.
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). |
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 (Fade walls near the camera). |
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). |
annotate(...), clearAnnotations(...) |
Pinned annotations (annotations). |
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.
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#
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.
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 VIEWFITs are fitted together, with the options of the last one that gives any.
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#
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 (get#arithmetic, functions#numbers), followed by an optional UNIT to show it in (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 (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.
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#
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.
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#
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), 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 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.
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#
An action set may end with a subject: a virtual shape (BOX, CYLINDER, CONE, SPHERE of 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.
if (type = IFCSPACE) { COLOR "#3070b3" 40% MAXIMUM_INSCRIBED_CYLINDER(geometry3d, 2.1 m); }Parameters#
$name in a condition is bound at run time exactly as in BQL (using#parameters); ResolveBvl takes the same parameters object.
if (qid IN $selection) { COLOR "orange" SELECT; } else { COLOR RESET 70%; }Common mistakes#
- A missing
;after an action set. COLOR #800080— colours are strings:COLOR "#800080".COLOR "auto"orCOLOR "RESET"— keywords, not strings.- Action sets before
groupblocks, orifblocks before action sets — the order inside a block is fixed. - Conditions on
*TYPEclasses select nothing visible (types#occurrences).
Used in#
- Use the Actions tree — storing and running a visualisation.
- reference/bcl#actions — BVL inside a check.
- reference/brl#viewports — BVL as viewport style.
Pages#
- BVL grammarThe Xtext grammar of BVL as shipped in this release.