ViewerApi
PHP SDK: the Viewer operations, 1 method, each with its parameters, result and a complete example.
PHP SDK · BIMworks\Api · class · 1 method
What the viewers need to place and load models
Construct it with the client of the connect step: new ViewerApi(config: $client). Each method is one operation of the API part, where it runs on its page.
| Method | Operation | Description |
|---|---|---|
getGeometryMetaData | GetGeometryMetaData | What a viewer needs to place and load models |
getGeometryMetaData#
public function getGeometryMetaData(GetGeometryMetaDataRequest $get_geometry_meta_data_request): array<string,array<string,mixed>>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.
| Operation | GetGeometryMetaData · POST /openapi/viewer/GetGeometryMetaData |
|---|---|
| Scope | geometry:read |
Parameters#
| Name | Type | Description |
|---|---|---|
get_geometry_meta_data_request | GetGeometryMetaDataRequestrequired | The request: its properties are those of the model, its JSON that of GetGeometryMetaData's request body. |
Returns#
array<string,array<string,mixed>> — The metadata per Version uuid
Example#
<?php
require __DIR__ . '/vendor/autoload.php';
use BIMworks\Api\AuthApi;
use BIMworks\Api\ViewerApi;
use BIMworks\Configuration;
use BIMworks\Model\GetGeometryMetaDataRequest;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;
// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('https://bim.works/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => "<your API token>"]));
$client->setAccessToken($auth->getBase64());
// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
"models": [
{
"type": "UrlModelIdentifier"
}
]
}
JSON, GetGeometryMetaDataRequest::class);
// 3. The call
$result = (new ViewerApi(config: $client))->getGeometryMetaData($request);
// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;