How-to guide·QueryRequires VIRTUAL_FEATURESRequires DATA_FILES

Query models that use different classification systems

Define one virtual classification that reads NL-SfB where a model has it and translates Uniclass where it does not, so a query names one code instead of an OR per system.

For a project whose models come from several parties: the architect classifies with NL-SfB, the installer with Uniclass, and every query that wants "the external walls" has to name both. A virtual feature moves that knowledge out of the queries: you define once how a project code follows from what each model holds, and query the project code.

Before you start#

  • A workspace you manage that has the Virtual features feature (VIRTUAL_FEATURES) — your personal workspace has it when your account does — and the Data files feature (DATA_FILES) to upload the crosswalk. The definition belongs to that workspace and applies to everyone who works in it (reference/bfl#workspaces).
  • A crosswalk between the two systems as a CSV file: one column per system, one row per pair of codes.
Text#
uniclass,nlsfb
Ss_25_10_30,21.22
Ss_25_10_32,22.11
Pr_30_59_24,31.21

1. Upload the crosswalk#

In the workspace's actions tree, create a folder codes and add the CSV to it as a data file, named crosswalk.csv. A definition addresses it by its path below the workspace's actions folder: codes/crosswalk.csv.

2. Define the virtual classification#

Open the workspace's page (the workspace switcher → Workspace settings), choose Virtual features, then + New and Classification. Give it a name and replace the text:

BFL#
DEFINE classification "Project NL-SfB"
AS COALESCE(
	classification[system.name CONTAINS "SfB"].identification,
	LOOKUP("codes/crosswalk.csv", classification[system.name CONTAINS "Uniclass"].identification, "uniclass", "nlsfb")
)

COALESCE takes the first value there is: the model's own NL-SfB code, and otherwise the Uniclass code translated through the file. The strip under the editor shows the path the feature is read through and what it builds on; an error in the text, a missing file or a missing column shows there as you type.

Preview runs the text as it stands on the models you have loaded and lists the values with their counts — before anything is saved. A row selects its objects in the viewer.

Save stores the definition and switches it on.

3. Query the project code#

Every model now answers to one system, whatever it stores:

BQL#
GET qid, attribute.Name WHERE classification[system.name = "Project NL-SfB"].identification STARTS_WITH "21"
BQL#
GET classification.identification, COUNT(qid) GROUP BY classification.identification

In the features panel the entry appears under Classifications with a (V); hovering it shows the definition it came from.

Names for the codes#

A code list — a CSV with the columns code and name — gives every entry its name: add NAMES FROM "codes/nlsfb.csv" after the system name (reference/bfl#lookup).

From the API#

A request applies virtual features only when it asks for them: send "virtual_features": "enabled" with Query2, QueryCount or TableExport, or name the definitions by uuid (reference/bfl#apply). The set is that of the workspace the request works in — its workspace_uuid, else your default workspace — so a stored action gives everyone in a workspace the same values.