Reference·JavaScript · @bimworks/jssdkJavaScript

Bim

Class in @bimworks/jssdk.

API catalogue · @bimworks/jssdk · Class

TypeScript#
class Bim

API Namespace BIM is used for BIM related API calls.

Members#

Member Kind Description
constructor Method
aliasKeys Property Whether the queries of this client put values under their AS aliases by default; change it with Bim.setAliasKeys
virtualFeatures Property The virtual-feature selection every query of this client sends by default; change it with Bim.setVirtualFeatures
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…
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…
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
getDiscipline Method Get the discipline of the given Version. Fails with NO_DISCIPLINE when none is set.
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…
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 …
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 …
query Method Query one or more model versions. Records follow the GET columns; dotted features are nested objects.
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…
queryCount Method Count the objects a query matches without retrieving the records.
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…
queryGroupsAsTask Method As Bim.queryGroups with a group path, returning the Task; its success handler receives {groupPath, groupLevel, groups, objects}
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 …
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…
queryQidsAsTask Method As Bim.queryQids, returning the Task; its success handler receives a QidSet
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…
setDiscipline Method Set the discipline of the given Version
setDisciplines Method Set the multi-label disciplines of the given Version. The first entry becomes the primary; an empty array clears all discipline fields.
setVirtualFeatures Method Sets the default virtual-feature selection ("enabled", "none", uuids, ...); cached query results are dropped. The virtual features are those of the workspace…
validateQuery Method Validate a BQL query without running it

constructor#

TypeScript#
constructor()

aliasKeys#

TypeScript#
public readonly aliasKeys: boolean

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

virtualFeatures#

TypeScript#
public readonly virtualFeatures: unknown

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

clashes#

TypeScript#
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#

TypeScript#
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#

TypeScript#
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 CallOptions

getDiscipline#

TypeScript#
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#

TypeScript#
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#

TypeScript#
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#

TypeScript#
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#

TypeScript#
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 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#

TypeScript#
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 QueryHelper)
useCache boolean
forceGetQid boolean
parameters Record<string, unknown> | null

queryCount#

TypeScript#
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#

TypeScript#
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#

TypeScript#
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#

TypeScript#
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#

TypeScript#
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 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 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 QidSet

queryQidsAsTask#

TypeScript#
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 QidSet

Parameters#

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

setAliasKeys#

TypeScript#
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 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#

TypeScript#
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#

TypeScript#
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#

TypeScript#
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#

TypeScript#
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