---
title: Bim
summary: Class in @bimworks/jssdk.
order: 10
languages: [javascript]
sdk-package: JavaScript · @bimworks/jssdk
---

# Bim

[[page:reference/javascript/api|API catalogue]] · `@bimworks/jssdk` · Class

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
class Bim
````

API Namespace BIM is used for BIM related API calls.

## Members

| Member | Kind | Description |
|---|---|---|
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-constructor-778019eb78fa|constructor]] | Method |  |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-aliaskeys-41728063d580|aliasKeys]] | Property | Whether the queries of this client put values under their `AS` aliases by default; change it with Bim.setAliasKeys |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-virtualfeatures-a38695cd7a2c|virtualFeatures]] | Property | The virtual-feature selection every query of this client sends by default; change it with Bim.setVirtualFeatures |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-clashes-99d5bfd54fe6|clashes]] | Method | The clashes between the objects of two BQL conditions on two versions (task CalculateClashes2, the pure-Java detector). Resolves to the pairs (each with qid1… |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-classifyversion-b6377674e460|classifyVersion]] | Method | Re-run the discipline classifier for the Version's model content. Applies the result to the version unless its discipline was set by a user. Returns the clas… |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-downloadfullexport-2cc1c9480dda|downloadFullExport]] | Method | A full export of the versions; resolves with its download URL. `options.ui`: the part of the UI a person asked this from |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-getdiscipline-128a64504673|getDiscipline]] | Method | Get the discipline of the given Version. Fails with NO_DISCIPLINE when none is set. |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-getdisciplineclassification-50a83a64e96e|getDisciplineClassification]] | Method | The stored automatic discipline classification of the Version's model content — scores, tags and the evidence breakdown. Fails with NO_DISCIPLINE when none i… |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-listavailabledisciplines-ac2b1841f950|listAvailableDisciplines]] | Method | List all available disciplines, in enum order: the name, the display name and the umbrella value it specializes (null for a top-level value). A filter on an … |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-listbuildingstoreys-298002a54ba7|listBuildingStoreys]] | Method | The building storeys of the models, merged across models. Using "any" on purpose here, otherwise crazy casting required. Each merged storey lists its member … |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-query-1b6409899c86|query]] | Method | Query one or more model versions. Records follow the GET columns; dotted features are nested objects. |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-queryastask-75686b4b5efe|queryAsTask]] | Method | As Bim.query, but returns the Task instead of running it, so progress and error handlers can be attached first. The task's success handler receives the resul… |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-querycount-3b272cd91aae|queryCount]] | Method | Count the objects a query matches without retrieving the records. |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-querygroups-3b0523d47269|queryGroups]] | Method | One slice of a grouped query (GROUP BY slice mode): the groups below the addressed group, or, when the path names a leaf group, its member objects. A group i… |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-querygroupsastask-346a9a85c546|queryGroupsAsTask]] | Method | As Bim.queryGroups with a group path, returning the Task; its success handler receives `{groupPath, groupLevel, groups, objects}` |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-queryoids-d7139b5cf058|queryOids]] | Method | The objects a query matches as bare ids, without a record being written or parsed: the cheap way to get the members of something large. The query is a plain … |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-queryqids-01483ea34f38|queryQids]] | Method | Specialized (and optimized) call to execute a query and get the results as a QidSet. Regardless of any GET statements that are included in the BQL query, onl… |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-queryqidsastask-2cac246f122e|queryQidsAsTask]] | Method | As Bim.queryQids, returning the Task; its success handler receives a QidSet |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-setaliaskeys-da18d9988f1f|setAliasKeys]] | Method | Since 3.0 an `AS` alias only names its column: every value stays where it is without one, and the records' `columns` say where each `GET` item is (read value… |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-setdiscipline-15cdf583a91f|setDiscipline]] | Method | Set the discipline of the given Version |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-setdisciplines-758a6636aa63|setDisciplines]] | Method | Set the multi-label disciplines of the given Version. The first entry becomes the primary; an empty array clears all discipline fields. |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-setvirtualfeatures-0ee1b7280498|setVirtualFeatures]] | Method | Sets the default virtual-feature selection ("enabled", "none", uuids, ...); cached query results are dropped. The virtual features are those of the workspace… |
| [[page:reference/javascript/bimworks-jssdk/bim-635ea161#member-validatequery-43615c9cb69f|validateQuery]] | Method | Validate a BQL query without running it |

## `constructor` {#member-constructor-778019eb78fa}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
constructor()
````



## `aliasKeys` {#member-aliaskeys-41728063d580}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public readonly aliasKeys: boolean
````

Whether the queries of this client put values under their `AS` aliases by default; change it with `Bim.setAliasKeys`

## `virtualFeatures` {#member-virtualfeatures-a38695cd7a2c}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public readonly virtualFeatures: unknown
````

The virtual-feature selection every query of this client sends by default; change it with `Bim.setVirtualFeatures`

## `clashes` {#member-clashes-99d5bfd54fe6}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public clashes(versionUuid1: string, query1: string, versionUuid2: string, query2: string, options?: { margin_mm?: number; predicate?: "INTERSECTS" | "TOUCHES" | "CONTAINS" | "CONTAINED_IN"; with_stats?: boolean }): Promise<unknown>
````

The clashes between the objects of two BQL conditions on two versions (task CalculateClashes2, the
pure-Java detector). Resolves to the pairs (each with qid1, qid2 and the detector's verdict: kind,
tier, depth), or with `options.with_stats` to `{clashes: [...], stats: {...}}`.

### Parameters

| Name | Type | Description |
|---|---|---|
| `versionUuid1` | `string` |  |
| `query1` | `string` |  |
| `versionUuid2` | `string` |  |
| `query2` | `string` |  |
| `options` | `{ margin_mm?: number; predicate?: "INTERSECTS" \| "TOUCHES" \| "CONTAINS" \| "CONTAINED_IN"; with_stats?: boolean }` |  |

## `classifyVersion` {#member-classifyversion-b6377674e460}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public classifyVersion(versionUuid: string): Promise<unknown>
````

Re-run the discipline classifier for the Version's model content. Applies the result
to the version unless its discipline was set by a user. Returns the classification badge.

### Parameters

| Name | Type | Description |
|---|---|---|
| `versionUuid` | `string` | the Vid of the Version |

## `downloadFullExport` {#member-downloadfullexport-2cc1c9480dda}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public downloadFullExport(versionUuids: Iterable<string>, options?: CallOptions): Promise<string>
````

A full export of the versions; resolves with its download URL. `options.ui`: the part of the UI a person asked this from

### Parameters

| Name | Type | Description |
|---|---|---|
| `versionUuids` | `Iterable<string>` |  |
| `options` | [[page:reference/javascript/bimworks-jssdk/calloptions-de0ee685|CallOptions]] |  |

## `getDiscipline` {#member-getdiscipline-128a64504673}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public getDiscipline(versionUuid: string): Promise<Discipline>
````

Get the discipline of the given Version. Fails with NO_DISCIPLINE when none is set.

### Parameters

| Name | Type | Description |
|---|---|---|
| `versionUuid` | `string` | the Vid of the Version |

## `getDisciplineClassification` {#member-getdisciplineclassification-50a83a64e96e}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public getDisciplineClassification(versionUuid: string): Promise<unknown>
````

The stored automatic discipline classification of the Version's model content —
scores, tags and the evidence breakdown. Fails with NO_DISCIPLINE when none is stored.

### Parameters

| Name | Type | Description |
|---|---|---|
| `versionUuid` | `string` | the Vid of the Version |

## `listAvailableDisciplines` {#member-listavailabledisciplines-ac2b1841f950}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public listAvailableDisciplines(): Promise<({ name: Discipline; nice_name: string; parent: Discipline | null })[]>
````

List all available disciplines, in enum order: the name, the display name and the umbrella
value it specializes (null for a top-level value). A filter on an umbrella value matches its
descendants.

## `listBuildingStoreys` {#member-listbuildingstoreys-298002a54ba7}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public listBuildingStoreys(models: Iterable<string>, options?: { placements?: boolean }): Promise<unknown>
````

The building storeys of the models, merged across models. Using "any" on purpose here, otherwise crazy casting
required. Each merged storey lists its member storeys in `buildingStoreys`, each with `elevation_mm` (its
Elevation attribute in millimetres) and, with `options.placements`, `placement_z_mm`: the z of its absolute
placement in millimetres, the site's elevation included, which the merged storey's `elevation` (in the
last member's model unit) leaves out.

### Parameters

| Name | Type | Description |
|---|---|---|
| `models` | `Iterable<string>` |  |
| `options` | `{ placements?: boolean }` |  |

## `query` {#member-query-1b6409899c86}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public query(models: Iterable<string>, query: string, useCache?: boolean | BimQueryOptions, forceGetQid?: boolean, parameters?: Record<string, unknown>): Promise<QueryRecords>
````

Query one or more model versions. Records follow the GET columns; dotted features are nested objects.

### Parameters

| Name | Type | Description |
|---|---|---|
| `models` | `Iterable<string>` | One or more version UUIDs |
| `query` | `string` | The query (BQL) to execute |
| `useCache` | `boolean \| BimQueryOptions` | Whether the results should internally be cached so that future calls to the same query+models are faster. Defaults to false. Use this judiciously as the results are cached in memory until the [[page:reference/javascript/bimworks-jssdk/bimworksclient-40a172f2|BimWorksClient]] is closed |
| `forceGetQid` | `boolean` | Queries without a GET statement will automatically returns Qids only, but BQL with a GET statement does not. Setting this parameter to true (default: false) forces Qids to be returned even when not included in the GET statement |
| `parameters` | `Record<string, unknown>` |  |

### Returns

A Promise of the records; `columns` on the array says where each GET item is in them, and its alias

## `queryAsTask` {#member-queryastask-75686b4b5efe}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public queryAsTask(models: Iterable<string>, query: string | object, useCache?: boolean, forceGetQid?: boolean, parameters?: Record<string, unknown> | null): Task
````

As `Bim.query`, but returns the Task instead of running it, so progress and error handlers can be attached first.
The task's success handler receives the result objects.

### Parameters

| Name | Type | Description |
|---|---|---|
| `models` | `Iterable<string>` |  |
| `query` | `string \| object` | BQL text, or a parsed query (see [[page:reference/javascript/bimworks-jssdk/queryhelper-a2ca8c5a|QueryHelper]]) |
| `useCache` | `boolean` |  |
| `forceGetQid` | `boolean` |  |
| `parameters` | `Record<string, unknown> \| null` |  |

## `queryCount` {#member-querycount-3b272cd91aae}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public queryCount(models: Iterable<string>, query: string, useCache?: boolean, parameters?: Record<string, unknown>): Promise<number>
````

Count the objects a query matches without retrieving the records.

### Parameters

| Name | Type | Description |
|---|---|---|
| `models` | `Iterable<string>` | One or more version UUIDs |
| `query` | `string` | BQL query; a grouped query counts groups |
| `useCache` | `boolean` | Reserved compatibility argument; this method does not cache results |
| `parameters` | `Record<string, unknown>` | Named BQL parameter values, without the leading dollar sign |

### Returns

The count returned by the QueryCount task

## `queryGroups` {#member-querygroups-3b0523d47269}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public queryGroups(models: Iterable<string>, query: string, options?: { aliasKeys?: boolean; groupKeys?: (string)[]; groupPath?: (number)[]; parameters?: object; virtualFeatures?: unknown }): Promise<{ columns: (QueryColumn)[] | null; groupLevel: number; groups: (unknown)[] | null; objects: (unknown)[] | null }>
````

One slice of a grouped query (GROUP BY slice mode): the groups below the addressed group, or, when the path names a leaf group, its member objects.
A group is addressed by `groupKeys` (the `groupKey` every slice record carries; keeps its meaning when the set of models changes) or by `groupPath` (indices into each level's sorted groups; only valid for one set of models). Without either: the first level.

### Parameters

| Name | Type | Description |
|---|---|---|
| `models` | `Iterable<string>` | The Vids of the models that you want to query |
| `query` | `string` | A BQL query with a GROUP BY |
| `options` | `{ aliasKeys?: boolean; groupKeys?: (string)[]; groupPath?: (number)[]; parameters?: object; virtualFeatures?: unknown }` |  |

### Returns

A Promise of `{groupLevel, groups, objects, columns}`, one of `groups` and `objects` being null

## `queryGroupsAsTask` {#member-querygroupsastask-346a9a85c546}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public queryGroupsAsTask(models: Iterable<string>, query: string | object, groupPath: (number)[], forceGetQid?: boolean): Task
````

As `Bim.queryGroups` with a group path, returning the Task; its success handler receives `{groupPath, groupLevel, groups, objects}`

### Parameters

| Name | Type | Description |
|---|---|---|
| `models` | `Iterable<string>` |  |
| `query` | `string \| object` |  |
| `groupPath` | `(number)[]` |  |
| `forceGetQid` | `boolean` |  |

## `queryOids` {#member-queryoids-d7139b5cf058}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public queryOids(models: Iterable<string>, query: string, options?: { groupKeys?: (string)[]; groupPath?: (number)[]; parameters?: object; virtualFeatures?: unknown }): Promise<Map<string, Int32Array<ArrayBuffer>>>
````

The objects a query matches as bare ids, without a record being written or parsed: the cheap way to get the members of something large.
The query is a plain one (no aggregate, no ORDER BY), or a grouped one with `groupKeys` / `groupPath` addressing a group at any level: its members.

### Parameters

| Name | Type | Description |
|---|---|---|
| `models` | `Iterable<string>` | The Vids of the models that you want to query |
| `query` | `string` | The query to execute |
| `options` | `{ groupKeys?: (string)[]; groupPath?: (number)[]; parameters?: object; virtualFeatures?: unknown }` |  |

### Returns

A Promise of a Map of version uuid to the ascending oids of that version

## `queryQids` {#member-queryqids-01483ea34f38}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public queryQids(models: Iterable<string>, query: string, useCache?: boolean | Pick<BimQueryOptions, "useCache" | "parameters" | "virtualFeatures" | "ui">, parameters?: Record<string, unknown> | null): Promise<QidSet>
````

Specialized (and optimized) call to execute a query and get the results as a [[page:reference/javascript/bimworks-jssdk/qidset-48ad2c6e|QidSet]]. Regardless of any GET statements that are included in the BQL query, only Qids will be retrieved

### Parameters

| Name | Type | Description |
|---|---|---|
| `models` | `Iterable<string>` | The Vids of the models that you want to query |
| `query` | `string` | The query to execute |
| `useCache` | `boolean \| Pick<BimQueryOptions, "useCache" \| "parameters" \| "virtualFeatures" \| "ui">` | Whether the results should internally be cached so that future calls to the same query+models are faster. Defaults to false. Use this judiciously as the results are cached in memory until the [[page:reference/javascript/bimworks-jssdk/bimworksclient-40a172f2|BimWorksClient]] is closed. Or the options: `useCache`, `parameters`, `virtualFeatures` and `ui`, as for `Bim.query` |
| `parameters` | `Record<string, unknown> \| null` | Named BQL parameter values, without the leading dollar sign |

### Returns

A Promise that resolves to a [[page:reference/javascript/bimworks-jssdk/qidset-48ad2c6e|QidSet]]

## `queryQidsAsTask` {#member-queryqidsastask-2cac246f122e}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public queryQidsAsTask(models: Iterable<string>, query: string | object, parameters?: Record<string, unknown> | null): Task
````

As `Bim.queryQids`, returning the Task; its success handler receives a [[page:reference/javascript/bimworks-jssdk/qidset-48ad2c6e|QidSet]]

### Parameters

| Name | Type | Description |
|---|---|---|
| `models` | `Iterable<string>` |  |
| `query` | `string \| object` |  |
| `parameters` | `Record<string, unknown> \| null` |  |

## `setAliasKeys` {#member-setaliaskeys-da18d9988f1f}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public setAliasKeys(aliasKeys: boolean): void
````

Since 3.0 an `AS` alias only names its column: every value stays where it is without one, and the records'
`columns` say where each `GET` item is (read values by alias with [[page:reference/javascript/bimworks-jssdk/querycolumns-de03e166|QueryColumns]]). True keeps the
placement of before for every query of this client, where an alias moved the value of most features to a root
key of that name: for code written against it. Cached query results are dropped.

### Parameters

| Name | Type | Description |
|---|---|---|
| `aliasKeys` | `boolean` |  |

## `setDiscipline` {#member-setdiscipline-15cdf583a91f}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public setDiscipline(versionUuid: string, discipline: Discipline | null): Promise<void>
````

Set the discipline of the given Version

### Parameters

| Name | Type | Description |
|---|---|---|
| `versionUuid` | `string` | the Vid of the Version |
| `discipline` | `Discipline \| null` | The new discipline, or null to clear it |

## `setDisciplines` {#member-setdisciplines-758a6636aa63}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public setDisciplines(versionUuid: string, disciplines: (Discipline)[]): Promise<void>
````

Set the multi-label disciplines of the given Version. The first entry becomes the
primary; an empty array clears all discipline fields.

### Parameters

| Name | Type | Description |
|---|---|---|
| `versionUuid` | `string` | the Vid of the Version |
| `disciplines` | `(Discipline)[]` | The disciplines, primary first |

## `setVirtualFeatures` {#member-setvirtualfeatures-0ee1b7280498}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public setVirtualFeatures(virtualFeatures: unknown): void
````

Sets the default virtual-feature selection ("enabled", "none", uuids, ...); cached query results are dropped.
The virtual features are those of the workspace a query works in: "enabled" applies that workspace's enabled set.

### Parameters

| Name | Type | Description |
|---|---|---|
| `virtualFeatures` | `unknown` |  |

## `validateQuery` {#member-validatequery-43615c9cb69f}

````typescript sdk=js sdk-namespace="@bimworks/jssdk"
public validateQuery(query: string): Promise<{ messages: (QueryValidationMessage)[] }>
````

Validate a BQL query without running it

### Parameters

| Name | Type | Description |
|---|---|---|
| `query` | `string` |  |

### Returns

A Promise that fails with the error (SYNTAX_ERROR, with line and column) when the query does not parse, and otherwise resolves to
the validator's warnings and errors about it (an IFC class in the wrong case, an unknown attribute, ...); `messages` is empty for a clean query
