Reference·TypeScript SDK · @bimworks/sdkTypeScript

ViewerApi

TypeScript SDK: the Viewer operations, 1 method, each with its parameters, result and a complete example.

TypeScript SDK · @bimworks/sdk · class · 1 method

What the viewers need to place and load models

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

MethodOperationDescription
getGeometryMetaDataGetGeometryMetaDataWhat a viewer needs to place and load models

getGeometryMetaData#

TypeScript#
getGeometryMetaData(requestParameters: { getGeometryMetaDataRequest: GetGeometryMetaDataRequest }): Promise<{ [key: string]: { [key: string]: any; }; }>

What a viewer needs to place and load models. Per Version (keyed by its uuid): the metadata of its geometry (bounds, units, the unquantization, the file types and the geometry encoding the viewer should load), and its placement (georeference, anchor point, alignment, grid convergence). The keys follow the indexed-model metadata, which the viewers read as they are.

OperationGetGeometryMetaData · POST /openapi/viewer/GetGeometryMetaData
Scopegeometry:read

Parameters#

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

Returns#

{ [key: string]: { [key: string]: any; }; } — The metadata per Version uuid

Example#

TypeScript#
import { AuthApi, Configuration, GetGeometryMetaDataRequestFromJSON, ViewerApi } from "@bimworks/sdk";

// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
  .loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });

// 2. The request
const request = GetGeometryMetaDataRequestFromJSON({
  "models": [
    {
      "type": "UrlModelIdentifier"
    }
  ]
});

// 3. The call
const result = await new ViewerApi(client).getGeometryMetaData({ getGeometryMetaDataRequest: request });

// 4. The result
console.log(JSON.stringify(result, null, 2));