Reference·Python SDK · bimworksPython

IFCApi

Python SDK: the IFC - Industry Foundation Classes operations, 21 methods, each with its parameters, result and a complete example.

Python SDK · bimworks · class · 21 methods

IFC related calls, for example queries and model checks

Construct it with the client of the connect step: bimworks.IFCApi(client). Each method is one operation of the API part, where it runs on its page.

MethodOperationDescription
checkCheckCheck one or more models
commit_transactionCommitTransactionCommit a BUL transaction against the head Version of a Node, producing a new Version
compare_modelsCompareModelsCompare two models with a BCOL definition
compare_objectsCompareObjectsCompare two chosen objects
delete_compare_pair_overrideDeleteComparePairOverrideTake a pair fixed by hand away again
export_compare_resultExportCompareResultDownload a stored compare result (deprecated, use GetCompareResult with a format)
get_compare_bulGetCompareBulThe changes between two Versions as BUL
get_compare_resultGetCompareResultRead a stored compare result
get_match_candidatesGetMatchCandidatesThe added objects that could be a removed object
get_object_historyGetObjectHistoryThe change history of one object
get_version_changesGetVersionChangesWhat changed in Versions since the Versions before them
list_building_storeysListBuildingStoreysThe building storeys of one or more models
list_compare_pair_overridesListComparePairOverridesThe pairs fixed by hand for two Versions
map_qidsMapQidsMap objects of one Version to their counterparts in another
parse_queryParseQueryParse a BQL query into its syntax tree
queryQueryQuery one or more IFC models
record_upload_as_transactionRecordUploadAsTransactionReplace an upload by a transaction with the same changes
resolve_bvlResolveBvlResolve a BVL script to what it shows, hides, selects and colours
set_compare_pair_overrideSetComparePairOverrideFix a pair by hand for two Versions
text_searchTextSearchFree-text search in models
upgrade_syntaxUpgradeSyntaxRewrite BQL, BVL and BCL written for 2.x in the 3.0 syntax

check#

Python#
def check(self, check_request: CheckRequest) -> CheckResultsResponse

Check one or more models. Checks one or more models against an IDS definition (XML), a BCL definition (BIM.works Checking Language) or a stored check action. Pass exactly one of ids, bcl and action_uuid. A stored action is an IDS or a BCL (CHECK3) action; running it needs read rights on it, not actions:read.

OperationCheck · POST /openapi/ifc/Check
Scopechecks:run

Parameters#

NameTypeDescription
check_requestCheckRequestrequiredThe request: its properties are those of the model, its JSON that of Check's request body.

Returns#

CheckResultsResponse — The check results in the requested format

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.CheckRequest.from_json(r"""
{
  "models": [
    {
      "type": "VersionModelIdentifier",
      "uuid": "<version uuid of the first demo model>"
    }
  ],
  "ids": "<ids xmlns=\"http://standards.buildingsmart.org/IDS\">…</ids>"
}
""")

# 3. The call
result = bimworks.IFCApi(client).check(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

commit_transaction#

Python#
def commit_transaction(self, commit_transaction_request: CommitTransactionRequest) -> CommitTransactionResult

Commit a BUL transaction against the head Version of a Node, producing a new Version. Applies one or more BUL (BIM.works Update Language) statements to the given Version and creates a new Version on the same Node. The given Version must be the head (latest) Version of its Node: history is linear, and committing against an older Version fails with 409. The commit is atomic (either the complete new Version is created, or nothing is) and synchronous: the new Version is ready when the call returns.

OperationCommitTransaction · POST /openapi/ifc/CommitTransaction
Scopemodel:write

Parameters#

NameTypeDescription
commit_transaction_requestCommitTransactionRequestrequiredThe request: its properties are those of the model, its JSON that of CommitTransaction's request body.

Returns#

CommitTransactionResult — The transaction result. For a commit: transaction and node. For a dry run: updates, is_head and (only when the Version is not the head) head_version

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.CommitTransactionRequest.from_json(r"""
{
  "version_uuid": "<version uuid of the first demo model>",
  "bul": [
    "SET attribute.Name = \"Standard door\" WHERE type = IFCDOOR"
  ],
  "comment": "Normalize door names"
}
""")

# 3. The call
result = bimworks.IFCApi(client).commit_transaction(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

compare_models#

Python#
def compare_models(self, compare_models_request: CompareModelsRequest) -> CompareResult

Compare two models with a BCOL definition. Compares two models (usually two Versions of one Node, left the older one) and returns what was added, removed, changed and unchanged, by the categories of a BCOL (BIM.works Compare Language) definition: the built-in Default, another built-in definition, a stored compare action, or BCOL text.

OperationCompareModels · POST /openapi/ifc/CompareModels
Scopequery:run

Parameters#

NameTypeDescription
compare_models_requestCompareModelsRequestrequiredThe request: its properties are those of the model, its JSON that of CompareModels's request body.

Returns#

CompareResult — The compare result, at the requested detail level

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.CompareModelsRequest.from_json(r"""
{
  "left": {
    "models": [
      {
        "type": "VersionModelIdentifier",
        "uuid": "<version uuid of the first demo model>"
      }
    ]
  },
  "right": {
    "models": [
      {
        "type": "VersionModelIdentifier",
        "uuid": "<version uuid of the first demo model>"
      }
    ]
  }
}
""")

# 3. The call
result = bimworks.IFCApi(client).compare_models(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

compare_objects#

Python#
def compare_objects(self, compare_objects_request: CompareObjectsRequest) -> CompareObjectsResult

Compare two chosen objects. Compares two objects as one pair, whatever matching would say: of one model or of two. By default with the built-in everything definition. The answer says what differs (changed_features and changes, in the shape of a compare record) and what the definition watches.

OperationCompareObjects · POST /openapi/ifc/CompareObjects
Scopequery:run

Parameters#

NameTypeDescription
compare_objects_requestCompareObjectsRequestrequiredThe request: its properties are those of the model, its JSON that of CompareObjects's request body.

Returns#

CompareObjectsResult — What differs between the two objects

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.CompareObjectsRequest.from_json(r"""
{
  "left": "",
  "right": "",
  "bcol": "",
  "definition": "everything"
}
""")

# 3. The call
result = bimworks.IFCApi(client).compare_objects(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

delete_compare_pair_override#

Python#
def delete_compare_pair_override(self, delete_compare_pair_override_request: DeleteComparePairOverrideRequest) -> ComparePairOverrides

Take a pair fixed by hand away again. Needs read rights on both Versions and write rights on the right one.

OperationDeleteComparePairOverride · POST /openapi/ifc/DeleteComparePairOverride
Scopemodel:write

Parameters#

NameTypeDescription
delete_compare_pair_override_requestDeleteComparePairOverrideRequestrequiredThe request: its properties are those of the model, its JSON that of DeleteComparePairOverride's request body.

Returns#

ComparePairOverrides — What the two Versions still have

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.DeleteComparePairOverrideRequest.from_json(r"""
{
  "uuid": "<version uuid of the first demo model>"
}
""")

# 3. The call
result = bimworks.IFCApi(client).delete_compare_pair_override(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

export_compare_result#

Python#
def export_compare_result(self, export_compare_result_request: ExportCompareResultRequest) -> bytes

Download a stored compare result (deprecated, use GetCompareResult with a format). Deprecated: GetCompareResult with format (document for this operation's json) answers the same files, and a 202 with the status while the result is computed. This operation will be removed in a later release.

OperationExportCompareResult · POST /openapi/ifc/ExportCompareResult
Scopequery:run

Parameters#

NameTypeDescription
export_compare_result_requestExportCompareResultRequestrequiredThe request: its properties are those of the model, its JSON that of ExportCompareResult's request body.

Returns#

bytes — The file

Example#

Python#
import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.ExportCompareResultRequest.from_json(r"""
{
  "result_uuid": "00000000-0000-0000-0000-000000000000",
  "format": "xlsx",
  "categories": [
    ""
  ]
}
""")

# 3. The call
result = bimworks.IFCApi(client).export_compare_result(request)

# 4. The result
with open("export-compare-result.bin", "wb") as file:
    file.write(result)

get_compare_bul#

Python#
def get_compare_bul(self, get_compare_bul_request: GetCompareBulRequest) -> CompareBul

The changes between two Versions as BUL. The changes of a compare of two Versions written as BUL statements on the left Version, verified by a dry run of that Version, and the changes BUL cannot write, each with the reason. Values carry their IFC type (IFCPOSITIVELENGTHMEASURE(1200 mm)), moves and rotations become TRANSFORM statements, removed objects DELETE OBJECT; added objects, materials, relations and changed shapes are never BUL. The compare compares every value exactly and is stored like any other; the BUL is made once per compare result and kept with it. record says whether the right Version, an upload, can be replaced by a transaction with these changes (RecordUploadAsTransaction).

OperationGetCompareBul · POST /openapi/ifc/GetCompareBul
Scopequery:run

Parameters#

NameTypeDescription
get_compare_bul_requestGetCompareBulRequestrequiredThe request: its properties are those of the model, its JSON that of GetCompareBul's request body.

Returns#

CompareBul — The statements, the residual, the coverage and whether the upload can be recorded

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.GetCompareBulRequest.from_json(r"""
{
  "left_version_uuid": "00000000-0000-0000-0000-000000000000",
  "right_version_uuid": "00000000-0000-0000-0000-000000000000"
}
""")

# 3. The call
result = bimworks.IFCApi(client).get_compare_bul(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

get_compare_result#

Python#
def get_compare_result(self, get_compare_result_request: GetCompareResultRequest) -> CompareResult

Read a stored compare result. Reads a result of CompareModels by its result_uuid, at a detail level and a page of its records, or its status while it is computed. Requires read access to both sides, and the same feature visibility as the caller that computed it (otherwise compare the models again).

OperationGetCompareResult · POST /openapi/ifc/GetCompareResult
Scopequery:run

Parameters#

NameTypeDescription
get_compare_result_requestGetCompareResultRequestrequiredThe request: its properties are those of the model, its JSON that of GetCompareResult's request body.

Returns#

CompareResult — The result in the requested format, or for format json its status while it is computed

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.GetCompareResultRequest.from_json(r"""
{
  "result_uuid": "4d1f2a3b-5c6d-4e7f-8a9b-0c1d2e3f4a5b",
  "details": "changes",
  "limit": 100
}
""")

# 3. The call
result = bimworks.IFCApi(client).get_compare_result(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

get_match_candidates#

Python#
def get_match_candidates(self, get_match_candidates_request: GetMatchCandidatesRequest) -> MatchCandidates

The added objects that could be a removed object. For the review of a stored compare's unmatched objects. Per removed object the added objects that could be it, best first by the geometric matcher's cost (the distance between the box centres, the size, the type, the name). Objects a user confirmed are listed apart.

OperationGetMatchCandidates · POST /openapi/ifc/GetMatchCandidates
Scopequery:run

Parameters#

NameTypeDescription
get_match_candidates_requestGetMatchCandidatesRequestrequiredThe request: its properties are those of the model, its JSON that of GetMatchCandidates's request body.

Returns#

MatchCandidates — The removed objects with their candidates, the added objects, and what was confirmed

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.GetMatchCandidatesRequest.from_json(r"""
{
  "result_uuid": "00000000-0000-0000-0000-000000000000",
  "left_oids": [
    0
  ],
  "left_qids": [
    ""
  ],
  "limit": 5,
  "radius_mm": 10000
}
""")

# 3. The call
result = bimworks.IFCApi(client).get_match_candidates(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

get_object_history#

Python#
def get_object_history(self, get_object_history_request: GetObjectHistoryRequest) -> Dict[str, Optional[object]]

The change history of one object. Every transaction that changed the object (by its oid) in the Node's line of Versions, newest first (as ListTransactions), with what it changed, and the Version the object first appeared in. feature limits it to one feature (property.Pset_WallCommon.IsExternal); features_only answers only the features that ever changed.

OperationGetObjectHistory · POST /openapi/ifc/GetObjectHistory
Scopemodel:read

Parameters#

NameTypeDescription
get_object_history_requestGetObjectHistoryRequestrequiredThe request: its properties are those of the model, its JSON that of GetObjectHistory's request body.

Returns#

Dict[str, Optional[object]] — The history

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.GetObjectHistoryRequest.from_json(r"""
{
  "model": {
    "type": "UrlModelIdentifier"
  },
  "oid": 0,
  "feature": "",
  "features_only": false
}
""")

# 3. The call
result = bimworks.IFCApi(client).get_object_history(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

get_version_changes#

Python#
def get_version_changes(self, get_version_changes_request: GetVersionChangesRequest) -> VersionChangesResult

What changed in Versions since the Versions before them. The counts of the built-in Default compare of each Version with the Version before it on its Node (the highest version number below it among the Node's live, processed IFC Versions): added, removed, changed, unchanged and ignored objects. New uploads are compared automatically when the server has compare.auto_on_upload on. A Version nothing compared yet is compared now, in the background (pending), unless only_stored asks for stored results only. Read the full result with GetCompareResult or map objects with MapQids.

OperationGetVersionChanges · POST /openapi/ifc/GetVersionChanges
Scopequery:run

Parameters#

NameTypeDescription
get_version_changes_requestGetVersionChangesRequestrequiredThe request: its properties are those of the model, its JSON that of GetVersionChanges's request body.

Returns#

VersionChangesResult — Per Version its changes; for a single version_uuid the fields of that Version are also at the top level

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.GetVersionChangesRequest.from_json(r"""
{
  "version_uuid": "<version uuid of the first demo model>",
  "version_uuids": [
    "<version uuid of the first demo model>"
  ],
  "only_stored": false
}
""")

# 3. The call
result = bimworks.IFCApi(client).get_version_changes(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

list_building_storeys#

Python#
def list_building_storeys(self, list_building_storeys_request: ListBuildingStoreysRequest) -> BuildingStoreys

The building storeys of one or more models. The storeys of the models merged by name, highest first, each with the objects on it; the objects without a storey come last, under "[No BS]". What a storey picker or a walk mode needs in one call.

OperationListBuildingStoreys · POST /openapi/ifc/ListBuildingStoreys
Scopequery:run

Parameters#

NameTypeDescription
list_building_storeys_requestListBuildingStoreysRequestrequiredThe request: its properties are those of the model, its JSON that of ListBuildingStoreys's request body.

Returns#

BuildingStoreys — The storeys

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.ListBuildingStoreysRequest.from_json(r"""
{
  "models": [
    {
      "type": "UrlModelIdentifier"
    }
  ]
}
""")

# 3. The call
result = bimworks.IFCApi(client).list_building_storeys(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

list_compare_pair_overrides#

Python#
def list_compare_pair_overrides(self, list_compare_pair_overrides_request: ListComparePairOverridesRequest) -> ComparePairOverrides

The pairs fixed by hand for two Versions. The objects a user linked as one object, and the objects a user confirmed as really removed or added. Every compare of the two Versions uses them. Needs read rights on both Versions.

OperationListComparePairOverrides · POST /openapi/ifc/ListComparePairOverrides
Scopequery:run

Parameters#

NameTypeDescription
list_compare_pair_overrides_requestListComparePairOverridesRequestrequiredThe request: its properties are those of the model, its JSON that of ListComparePairOverrides's request body.

Returns#

ComparePairOverrides — The overrides, oldest first

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.ListComparePairOverridesRequest.from_json(r"""
{
  "left_version_uuid": "00000000-0000-0000-0000-000000000000",
  "right_version_uuid": "00000000-0000-0000-0000-000000000000"
}
""")

# 3. The call
result = bimworks.IFCApi(client).list_compare_pair_overrides(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

map_qids#

Python#
def map_qids(self, map_qids_request: MapQidsRequest) -> MapQidsResult

Map objects of one Version to their counterparts in another. The correspondence of a compare, for re-pointing stored object references after a new Version: every asked object of from_version with its counterpart in to_version, and the asked objects without one (added, removed, or outside the compare). Without via the built-in Default compare of the two Versions is used: a stored one in either direction (the automatic compare of an upload is one), else a new one.

OperationMapQids · POST /openapi/ifc/MapQids
Scopequery:run

Parameters#

NameTypeDescription
map_qids_requestMapQidsRequestrequiredThe request: its properties are those of the model, its JSON that of MapQids's request body.

Returns#

MapQidsResult — The pairs, aligned, and the unmatched objects

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.MapQidsRequest.from_json(r"""
{
  "from_version": "00000000-0000-0000-0000-000000000000",
  "to_version": "00000000-0000-0000-0000-000000000000",
  "qids": [
    ""
  ],
  "oids": [
    0
  ],
  "all": false,
  "via": "00000000-0000-0000-0000-000000000000"
}
""")

# 3. The call
result = bimworks.IFCApi(client).map_qids(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

parse_query#

Python#
def parse_query(self, parse_query_request: ParseQueryRequest) -> Dict[str, Optional[object]]

Parse a BQL query into its syntax tree. The BQL query as its JSON syntax tree (the BQL JSON serialization, each node with a __type), with the parameters bound when given. A query that does not parse answers SYNTAX_ERROR with the line and column. No model is read.

OperationParseQuery · POST /openapi/ifc/ParseQuery
Scopeany login

Parameters#

NameTypeDescription
parse_query_requestParseQueryRequestrequiredThe request: its properties are those of the model, its JSON that of ParseQuery's request body.

Returns#

Dict[str, Optional[object]] — The syntax tree

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.ParseQueryRequest.from_json(r"""
{
  "query": "",
  "parameters": {}
}
""")

# 3. The call
result = bimworks.IFCApi(client).parse_query(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

query#

Python#
def query(self, query_request: QueryRequest) -> object

Query one or more IFC models. Queries one or more models with BQL (BIM.works Query Language): the query text, or a stored query action by action_uuid. Running a stored query needs read rights on it, not actions:read.

OperationQuery · POST /openapi/ifc/Query
Scopequery:run

Parameters#

NameTypeDescription
query_requestQueryRequestrequiredThe request: its properties are those of the model, its JSON that of Query's request body.

Returns#

object — Query results in the requested format

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.QueryRequest.from_json(r"""
{
  "models": [
    {
      "type": "VersionModelIdentifier",
      "name": "My model name",
      "uuid": "<version uuid of the first demo model>"
    }
  ],
  "query": "GET attribute.GlobalId, attribute.Name WHERE type = IFCWALL AND property.*.IsExternal = true"
}
""")

# 3. The call
result = bimworks.IFCApi(client).query(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

record_upload_as_transaction#

Python#
def record_upload_as_transaction(self, record_upload_as_transaction_request: RecordUploadAsTransactionRequest) -> RecordUploadAsTransactionResult

Replace an upload by a transaction with the same changes. Records an uploaded Version as a transaction on the Version before it: the BUL of GetCompareBul is committed on the previous Version, and the upload is deleted the way deleting the last Version does (a soft delete: its data stays). The new Version takes the upload's place and number, keeps the previous Version's object ids, and so keeps the history of every object and what refers to it. Only for the last Version of its Node, made by an upload, with a previous Version, when every change of the two is in the BUL (record.possible of GetCompareBul). Needs write rights on the Node and the user feature BUL (Model editing); without the feature the call answers 403 USER_FEATURE_REQUIRED.

OperationRecordUploadAsTransaction · POST /openapi/ifc/RecordUploadAsTransaction
Scopemodel:write

Parameters#

NameTypeDescription
record_upload_as_transaction_requestRecordUploadAsTransactionRequestrequiredThe request: its properties are those of the model, its JSON that of RecordUploadAsTransaction's request body.

Returns#

RecordUploadAsTransactionResult — The committed transaction, the Node with its new Version, and the replaced upload

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.RecordUploadAsTransactionRequest.from_json(r"""
{
  "version_uuid": "<version uuid of the first demo model>",
  "comment": ""
}
""")

# 3. The call
result = bimworks.IFCApi(client).record_upload_as_transaction(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

resolve_bvl#

Python#
def resolve_bvl(self, resolve_bvl_request: ResolveBvlRequest) -> ResolvedActions

Resolve a BVL script to what it shows, hides, selects and colours. Runs a BVL (BIM.works Visualisation Language) script against one or more models and returns its effect, ready for a viewer: the objects to show, hide, select and fit, the colour per object, the labels and the annotations. The server evaluates every condition of the script (each one is a BQL expression); the client only applies the answer, in the JavaScript SDK with new BvlHelper(objectStateManager, viewer).processResults([answer]) of @bimworks/viewercommon.

OperationResolveBvl · POST /openapi/ifc/ResolveBvl
Scopeactions:read

Parameters#

NameTypeDescription
resolve_bvl_requestResolveBvlRequestrequiredThe request: its properties are those of the model, its JSON that of ResolveBvl's request body.

Returns#

ResolvedActions — The resolved actions

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.ResolveBvlRequest.from_json(r"""
{
  "models": [
    {
      "type": "VersionModelIdentifier",
      "uuid": "<version uuid of the first demo model>"
    }
  ],
  "bvl": "if (type = IFCWALL AND property.*.IsExternal = true) { COLOR \"red\" VIEWFIT; }"
}
""")

# 3. The call
result = bimworks.IFCApi(client).resolve_bvl(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

set_compare_pair_override#

Python#
def set_compare_pair_override(self, set_compare_pair_override_request: SetComparePairOverrideRequest) -> ComparePairOverrideSet

Fix a pair by hand for two Versions. Links two objects as one object (the manual matcher pairs them before every other matcher), or confirms that an object really was removed or added (no matcher pairs it). Every compare of the two Versions uses it from then on; a stored result made before is computed again. An earlier override of either object is replaced. Needs read rights on both Versions and write rights on the right one.

OperationSetComparePairOverride · POST /openapi/ifc/SetComparePairOverride
Scopemodel:write

Parameters#

NameTypeDescription
set_compare_pair_override_requestSetComparePairOverrideRequestrequiredThe request: its properties are those of the model, its JSON that of SetComparePairOverride's request body.

Returns#

ComparePairOverrideSet — The new override and every override of the two Versions

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.SetComparePairOverrideRequest.from_json(r"""
{
  "left_version_uuid": "00000000-0000-0000-0000-000000000000",
  "right_version_uuid": "00000000-0000-0000-0000-000000000000",
  "kind": "pair",
  "left_oid": 0,
  "right_oid": 0,
  "note": ""
}
""")

# 3. The call
result = bimworks.IFCApi(client).set_compare_pair_override(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

text_search#

Python#
def text_search(self, text_search_request: TextSearchRequest) -> TextSearchResult

Free-text search in models. Searches the text of the models (names and values of attributes, properties, quantities, classifications, materials, layers) for words, not with BQL. Each group says where the text matched, how many objects match there and which (at most max_qids_per_group). A query that is a GlobalId (22 characters, or a UUID) also finds that object exactly, as a value match on the attribute GlobalId. Needs text indexing on the instance (features.text_indexing). Not available in a workspace whose filter limits the objects.

OperationTextSearch · POST /openapi/ifc/TextSearch
Scopequery:run

Parameters#

NameTypeDescription
text_search_requestTextSearchRequestrequiredThe request: its properties are those of the model, its JSON that of TextSearch's request body.

Returns#

TextSearchResult — The matches

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.TextSearchRequest.from_json(r"""
{
  "models": [
    {
      "type": "UrlModelIdentifier"
    }
  ],
  "query": "",
  "fuzzy": true,
  "max_edits": 0,
  "prefix": true,
  "search_values": true,
  "search_names": true,
  "kind": "attribute",
  "set": "",
  "name": "",
  "type": "",
  "max_qids_per_group": 100
}
""")

# 3. The call
result = bimworks.IFCApi(client).text_search(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

upgrade_syntax#

Python#
def upgrade_syntax(self, upgrade_syntax_request: UpgradeSyntaxRequest) -> UpgradeSyntaxResponse

Rewrite BQL, BVL and BCL written for 2.x in the 3.0 syntax. For BQL, BVL and BCL texts that a client keeps itself, written for BIM.works 2.x: each text that no longer parses in 3.0 because of a known syntax change comes back in the 3.0 syntax, with the changes made. The known changes are the unit clause (IN mm is UNIT mm), CS LENGTH (is LENGTH) and names that 3.0 reserves as keywords (quoted: property.Dimensions."length", AS "status"). A text that parses already comes back as it is (UNCHANGED); a text with any other error comes back as it is too, with the 3.0 parser's message (NOT_REWRITTEN), also when it has known changes as well. Strings and comments are never changed. Up to 1000 texts per request, answered in the order they were sent. No model is read. A stored action needs no call: the instance rewrites its stored actions once, as new versions.

OperationUpgradeSyntax · POST /openapi/ifc/UpgradeSyntax
Scopeany login

Parameters#

NameTypeDescription
upgrade_syntax_requestUpgradeSyntaxRequestrequiredThe request: its properties are those of the model, its JSON that of UpgradeSyntax's request body.

Returns#

UpgradeSyntaxResponse — One result per input, in the order of the inputs

Example#

Python#
import json

import bimworks

# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
    bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64

# 2. The request
request = bimworks.UpgradeSyntaxRequest.from_json(r"""
{
  "inputs": [
    {
      "id": "wall-heights",
      "language": "BQL",
      "text": "GET qid, quantity.Qto_WallBaseQuantities.Height IN mm WHERE type = IFCWALL"
    },
    {
      "id": "lengths",
      "language": "BCL",
      "text": "select (type = IFCWALL) { require property.Dimensions.length > 0; }"
    }
  ]
}
""")

# 3. The call
result = bimworks.IFCApi(client).upgrade_syntax(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))