Reference·Java SDK · nl.bimbase.bimworks.sdkJava

ViewerApi

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

Java SDK · nl.bimbase.bimworks.sdk.api · 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#

Java#
public Map<String, Map<String, Object>> getGeometryMetaData(GetGeometryMetaDataRequest getGeometryMetaDataRequest) throws ApiException

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#

Map<String, Map<String, Object>> — The metadata per Version uuid

Example#

Java#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.ViewerApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.GetGeometryMetaDataRequest;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;

public class Example {
    public static void main(String[] args) throws Exception {
        // 1. Connect to BIM.works and log in with your API token
        ApiClient client = new ApiClient();
        client.updateBaseUri("https://bim.works/openapi");
        Auth auth = new AuthApi(client)
                .loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
                .getAuth();
        client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));

        // 2. The request
        GetGeometryMetaDataRequest request = client.getObjectMapper().readValue("""
                {
                  "models": [
                    {
                      "type": "UrlModelIdentifier"
                    }
                  ]
                }
                """, GetGeometryMetaDataRequest.class);

        // 3. The call
        var result = new ViewerApi(client).getGeometryMetaData(request);

        // 4. The result
        System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
    }
}