Convert 2.x queries to 3.0

Send the BQL queries, BVL visualisations and BCL checks your application keeps itself, written for BIM.works 2.x, in one request and get them back in the 3.0 syntax, with what changed, or with the error that is left for you to fix.

An application that keeps BQL, BVL or BCL texts of its own (in its code, its database or its configuration) and moves from 2.x to 3.0: UpgradeSyntax rewrites them to the 3.0 syntax, as many as you like up to 1000 per request. It makes the same rewrite the instance makes once to its own stored actions (changelog/v3-0/from-2-to-3#stored-actions), so you do not have to call it for those.

Before you start#

  • A login; the call needs no scope and reads no model.
  • The texts, each with its language: BQL, BVL or BCL.

1. Send the texts#

POST/openapi/ifc/UpgradeSyntaxUpgradeSyntax reference
Authorization
Bearer <auth token>
Content-Type
application/json
Body
1 2 3 4 5 6 7 8
Authorization: Bearer <auth token>
Content-Type: application/json
Accept: application/json
curl -X POST "$BIMWORKS_URL/openapi/ifc/UpgradeSyntax" \
  -H "Authorization: Bearer $BIMWORKS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "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; }" },
    { "id": "walls", "language": "BVL", "text": "if (type = IFCWALL) { SHOW; } else { HIDE; }" },
    { "id": "typo", "language": "BQL", "text": "GET qid WHER type = IFCWALL" }
  ]
}'
Send to see the response

id is optional: your own name for a text, given back with its result. The results come in the order of the inputs.

2. Read the results#

JSON#
{
  "results": [
    { "id": "wall-heights", "language": "BQL", "status": "REWRITTEN",
      "text": "GET qid, quantity.Qto_WallBaseQuantities.Height UNIT mm WHERE type = IFCWALL", "changes": ["IN → UNIT"] },
    { "id": "lengths", "language": "BCL", "status": "REWRITTEN",
      "text": "select (type = IFCWALL) { require property.Dimensions.\"length\" > 0; }", "changes": ["length → \"length\""] },
    { "id": "walls", "language": "BVL", "status": "UNCHANGED",
      "text": "if (type = IFCWALL) { SHOW; } else { HIDE; }", "changes": [] },
    { "id": "typo", "language": "BQL", "status": "NOT_REWRITTEN",
      "text": "GET qid WHER type = IFCWALL", "changes": [], "error": "line 1:9: missing EOF at 'WHER'" }
  ]
}
status text What to do
REWRITTEN the text in the 3.0 syntax; changes lists what changed store it in place of the old one
UNCHANGED the text as you sent it: it parses in 3.0 nothing
NOT_REWRITTEN the text as you sent it; error says where 3.0 fails fix it by hand (BQL changes in 3.0)

The exact message of error is the 3.0 parser's, line L:C: …, up to three errors.

What it changes#

Only the syntax changes from 2.x to 3.0 that have one right answer, and only where the 3.0 parser reports an error:

  • IN <unit> after a GET feature is UNIT <unit> (UNIT). IN (…), the list comparison of WHERE, is not touched.
  • CS LENGTH is LENGTH.
  • A set, property, quantity or alias name that 3.0 reserves as a keyword is quoted: property.Dimensions."length", AS "status", and in BVL and BCL also names such as ."top", ."left" and, in BCL, ."pick". Only the words that are new in 3.0 are quoted, so a 3.0 feature such as calculated.quantity.length stays as it is.

A text with any other error, such as a typo or a BCL that 2.x ran partly and 3.0 refuses, is not changed at all, also when it has one of these changes as well. Strings and comments are never changed.

IN mm → UNIT mm changes results: 2.x ignored the unit clause, 3.0 converts. If your application relied on the unconverted numbers, remove the clause instead.

A query that parses can still select other objects or return other values in 3.0, for example = null or COUNT(f); this call does not look at meaning. BQL changes in 3.0 lists those changes.

Check#

Run the rewritten texts on a 3.0 test instance, or validate them first (Validate a query).