Reference·.NET SDK · BIMworks.Sdk.NET

ViewerApi

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

.NET SDK · BIMworks.Sdk.Api · class · 1 method

What the viewers need to place and load models

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

MethodOperationDescription
GetGeometryMetaDataAsyncGetGeometryMetaDataWhat a viewer needs to place and load models

GetGeometryMetaDataAsync#

.NET#
Task<IGetGeometryMetaDataApiResponse> GetGeometryMetaDataAsync(GetGeometryMetaDataRequest getGeometryMetaDataRequest, CancellationToken cancellationToken = default)

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#

Dictionary<string, Dictionary<string, Object>> — The metadata per Version uuid

Example#

.NET#
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("https://bim.works" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<GetGeometryMetaDataRequest>("""
    {
      "models": [
        {
          "type": "UrlModelIdentifier"
        }
      ]
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IViewerApi>().GetGeometryMetaDataAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));