Download a model
Download the original file of a version, the same model as ifcXML or converted to IFC4, or a whole folder as a zip archive.
For an integration that needs the files back: an archive, a hand-over, a conversion by another tool. Four downloads exist, all on the model:read scope: the original file of a version, byte for byte as it was uploaded; the same model serialised as ifcXML; the same model converted to another IFC schema; and a zip of a folder with the latest version of every model in it.
Before you start#
- A login with the
model:readscope. Note that a viewer token issued with onlygeometry:readcannot download; that is the point of the split. - The version UUID (or, for the zip, the folder's node UUID), see List the tree.
1. The original file#
// The SDK answers with a URL that is valid for a short time
const url = await client.ifc.downloadOriginalIfc("<version uuid of the first demo model>");
window.location.href = url; // in a page: let the browser save it
const bytes = await (await fetch(url)).arrayBuffer(); // or read it yourselfimport java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
try (InputStream in = client.ifc.downloadModel(UUID.fromString("<version uuid of the first demo model>"))) {
Files.copy(in, Paths.get("house.ifc"), StandardCopyOption.REPLACE_EXISTING);
}import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.ModelApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.DownloadRequest;
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
DownloadRequest request = client.getObjectMapper().readValue("""
{
"type": "VersionModelIdentifier",
"uuid": "<version uuid of the first demo model>"
}
""", DownloadRequest.class);
// 3. The call
var result = new ModelApi(client).download(request);
// 4. The result
Files.move(result.toPath(), Path.of("download.ifc"), StandardCopyOption.REPLACE_EXISTING);
}
}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<DownloadRequest>("""
{
"type": "VersionModelIdentifier",
"uuid": "<version uuid of the first demo model>"
}
""", json);
// 3. The call
var response = await client.GetRequiredService<IModelApi>().DownloadAsync(request);
// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
using var output = File.Create("download.ifc");
await result.CopyToAsync(output);import { writeFileSync } from "node:fs";
import { AuthApi, Configuration, DownloadRequestFromJSON, ModelApi } 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 = DownloadRequestFromJSON({
"type": "VersionModelIdentifier",
"uuid": "<version uuid of the first demo model>"
});
// 3. The call
const result = await new ModelApi(client).download({ downloadRequest: request });
// 4. The result
writeFileSync("download.ifc", Buffer.from(await result.arrayBuffer()));<?php
require __DIR__ . '/vendor/autoload.php';
use BIMworks\Api\AuthApi;
use BIMworks\Api\ModelApi;
use BIMworks\Configuration;
use BIMworks\Model\DownloadRequest;
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'
{
"type": "VersionModelIdentifier",
"uuid": "<version uuid of the first demo model>"
}
JSON, DownloadRequest::class);
// 3. The call
$result = (new ModelApi(config: $client))->download($request);
// 4. The result
copy($result->getPathname(), 'download.ifc');import bimworks
# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64
# 2. The request
request = bimworks.DownloadRequest.from_json(r"""
{
"type": "VersionModelIdentifier",
"uuid": "<version uuid of the first demo model>"
}
""")
# 3. The call
result = bimworks.ModelApi(client).download(request)
# 4. The result
with open("download.ifc", "wb") as file:
file.write(result)The methods: downloadOriginalIfc on Ifc, IfcApi.downloadModel on IfcApi (an InputStream you close), ModelApi::download in PHP SDK. The .NET SDK has no download method; use the HTTP operations. Over HTTP there are two: Download with a model identifier in the body, and Version, a GET on /openapi/Versions/{uuid} that fits a download link:
Bearer <auth token>application/jsonAuthorization: Bearer <auth token>
Content-Type: application/json
Accept: application/jsoncurl -X POST "$BIMWORKS_URL/openapi/model/Download" \
-H "Authorization: Bearer $BIMWORKS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "VersionModelIdentifier",
"uuid": BIM_WORKS_FIRST_MODEL
}'The reply is the file with its original name in Content-Disposition and a content type by extension (application/ifc, application/e57, application/pdf, …). Most models are stored Brotli-compressed, and those are sent with Content-Encoding: br; every browser and curl --compressed decode that, a hand-written HTTP client must too. A version created by an edit transaction has no original file yet and answers TRANSACTION_ERROR.
2. As ifcXML#
The stored model is serialised on the first request and cached, so the first download of a version takes longer. The dialect follows the model's schema: ISO 10303-28 for IFC2X3, ifcXML4 for IFC4 and IFC4X3.
const url = await client.ifc.downloadIfcXml("<version uuid of the first demo model>");try (InputStream in = client.ifc.downloadIfcXml(UUID.fromString("<version uuid of the first demo model>"))) {
Files.copy(in, Paths.get("house.ifcxml"), StandardCopyOption.REPLACE_EXISTING);
}downloadIfcXml is on Ifc and IfcApi; over HTTP DownloadIfcXml takes the same body as Download and answers application/xml. The generated PHP client has no method for it yet.
Any IFC version can be downloaded this way, whatever it was uploaded as, and the other direction works as well: a version that was uploaded as ifcXML can be downloaded as STEP. The result of a query can be ifcXML too: Query with Accept: application/xml. In the app, the version dropdown offers ifcXML when the account has the IFC_XML feature, and labels an XML original Original (ifcXML). Schema validation of the XML against the XSD, and ifcJSON, are not available.
3. In another IFC schema#
An IFC2X3 model can be downloaded as IFC4. That is the one conversion that exists; every other pair of schemas is refused with SCHEMA_CONVERSION_NOT_SUPPORTED and a message that names the conversions that exist. A target schema that the model already has is no error: the model is then served as in step 1.
const converted = await client.ifc.downloadConverted("<version uuid of the first demo model>", "IFC4");
console.log(converted.conversion.status, converted.conversion.losses, converted.conversion.additions);
window.location.href = converted.url;try (InputStream in = client.ifc.downloadModel(UUID.fromString("<version uuid of the first demo model>"), "IFC4")) {
Files.copy(in, Paths.get("house_IFC4.ifc"), StandardCopyOption.REPLACE_EXISTING);
}downloadConverted is on Ifc, IfcApi.downloadModel with a target schema on IfcApi. Over HTTP it is Download with target_schema next to the model identifier:
Bearer <auth token>application/jsonAuthorization: Bearer <auth token>
Content-Type: application/json
Accept: application/jsoncurl -X POST "$BIMWORKS_URL/openapi/model/Download" \
-H "Authorization: Bearer $BIMWORKS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "VersionModelIdentifier",
"uuid": BIM_WORKS_FIRST_MODEL,
"target_schema": "IFC4"
}'What to know about the converted file:
- Objects keep their id. Every object that is in both files has the same express id and the same GlobalId in both, also when its entity changed (an
IfcElectricDistributionPointbecomes anIfcElectricDistributionBoard). Objects that the conversion created are numbered above the objects of the model. - Losses and additions are stated. The reply of the SDK holds
conversionwith the numbers; over HTTP the same numbers are in the response headersX-BimWorks-Conversion-Status,-Losses,-Additionsand-Errors. The header of the file itself names the conversion and the number of losses, so that the information stays with the file. - Every single loss and addition is in the log.
getSchemaConversionReportin the SDKs, SchemaConversionReport over HTTP: pass the version and thetarget_schema. The formatmarkdowngives the report as text,detailthe complete log. - It takes time once. The conversion of a large model takes minutes. The converted file is kept, so the second download of the same version is answered at once. The SDK methods wait up to 30 minutes.
- A version of any origin. The conversion reads the stored model, not the uploaded file, so a version that was made by a transaction is converted with its edits.
- Checked on request. With
validate: truethe converted file is held against the schema check before it is served, and so is the model, to compare. The file is valid when the conversion introduced no violation; the reply says so invalidation, over HTTP inX-BimWorks-Conversion-Validation. This about doubles the time of a conversion.
The download leaves the model as it is. To make the converted model a version of its own, which can be queried, viewed and edited, use the statement CONVERT SCHEMA TO IFC4 in a transaction (reference/bul#convert-schema), or Convert to IFC4… in the menu of the version in the web client.
4. A folder as a zip#
The archive holds the last version of every non-deleted model below the folder, with the tree paths as entry paths; it is generated while it streams, so large folders start arriving at once. Deleted nodes can be included with include_deleted.
try (InputStream in = client.fs.downloadAsZip(folderUuid, false)) {
Files.copy(in, Paths.get("project-a.zip"), StandardCopyOption.REPLACE_EXISTING);
}import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.FsApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.DownloadAsZipRequest;
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
DownloadAsZipRequest request = client.getObjectMapper().readValue("""
{
"uuid": "<folder uuid>"
}
""", DownloadAsZipRequest.class);
// 3. The call
var result = new FsApi(client).downloadAsZip(request);
// 4. The result
Files.move(result.toPath(), Path.of("download-as-zip.zip"), StandardCopyOption.REPLACE_EXISTING);
}
}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<DownloadAsZipRequest>("""
{
"uuid": "<folder uuid>"
}
""", json);
// 3. The call
var response = await client.GetRequiredService<IFsApi>().DownloadAsZipAsync(request);
// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
using var output = File.Create("download-as-zip.zip");
await result.CopyToAsync(output);import { writeFileSync } from "node:fs";
import { AuthApi, Configuration, DownloadAsZipRequestFromJSON, FsApi } 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 = DownloadAsZipRequestFromJSON({
"uuid": "<folder uuid>"
});
// 3. The call
const result = await new FsApi(client).downloadAsZip({ downloadAsZipRequest: request });
// 4. The result
writeFileSync("download-as-zip.zip", Buffer.from(await result.arrayBuffer()));<?php
require __DIR__ . '/vendor/autoload.php';
use BIMworks\Api\AuthApi;
use BIMworks\Api\FsApi;
use BIMworks\Configuration;
use BIMworks\Model\DownloadAsZipRequest;
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'
{
"uuid": "<folder uuid>"
}
JSON, DownloadAsZipRequest::class);
// 3. The call
$result = (new FsApi(config: $client))->downloadAsZip($request);
// 4. The result
copy($result->getPathname(), 'download-as-zip.zip');import bimworks
# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64
# 2. The request
request = bimworks.DownloadAsZipRequest.from_json(r"""
{
"uuid": "<folder uuid>"
}
""")
# 3. The call
result = bimworks.FsApi(client).download_as_zip(request)
# 4. The result
with open("download-as-zip.zip", "wb") as file:
file.write(result)FileSystemApi.downloadAsZip is on FileSystemApi, FsApi::downloadAsZip in PHP SDK; over HTTP DownloadAsZip. A node that is not a folder fails with NOT_A_FOLDER_NODE. The JavaScript SDK has no zip method in this release.
With format ZIP_ZST the answer is a .zip.zst (application/zstd): the same ZIP with its entries stored, compressed as a whole with zstd. It is usually about a third smaller than the regular ZIP and several times faster to produce, so it suits large folders. zstd -d project-a.zip.zst or 7-Zip turns it into project-a.zip; Windows Explorer and macOS Finder do not open it. In the web client, Download ZIP... asks which of the two to download.
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.FsApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.DownloadAsZipRequest;
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
DownloadAsZipRequest request = client.getObjectMapper().readValue("""
{
"uuid": "<folder uuid>",
"format": "ZIP_ZST"
}
""", DownloadAsZipRequest.class);
// 3. The call
var result = new FsApi(client).downloadAsZip(request);
// 4. The result
Files.move(result.toPath(), Path.of("download-as-zip.zip"), StandardCopyOption.REPLACE_EXISTING);
}
}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<DownloadAsZipRequest>("""
{
"uuid": "<folder uuid>",
"format": "ZIP_ZST"
}
""", json);
// 3. The call
var response = await client.GetRequiredService<IFsApi>().DownloadAsZipAsync(request);
// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
using var output = File.Create("download-as-zip.zip");
await result.CopyToAsync(output);import { writeFileSync } from "node:fs";
import { AuthApi, Configuration, DownloadAsZipRequestFromJSON, FsApi } 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 = DownloadAsZipRequestFromJSON({
"uuid": "<folder uuid>",
"format": "ZIP_ZST"
});
// 3. The call
const result = await new FsApi(client).downloadAsZip({ downloadAsZipRequest: request });
// 4. The result
writeFileSync("download-as-zip.zip", Buffer.from(await result.arrayBuffer()));<?php
require __DIR__ . '/vendor/autoload.php';
use BIMworks\Api\AuthApi;
use BIMworks\Api\FsApi;
use BIMworks\Configuration;
use BIMworks\Model\DownloadAsZipRequest;
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'
{
"uuid": "<folder uuid>",
"format": "ZIP_ZST"
}
JSON, DownloadAsZipRequest::class);
// 3. The call
$result = (new FsApi(config: $client))->downloadAsZip($request);
// 4. The result
copy($result->getPathname(), 'download-as-zip.zip');import bimworks
# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64
# 2. The request
request = bimworks.DownloadAsZipRequest.from_json(r"""
{
"uuid": "<folder uuid>",
"format": "ZIP_ZST"
}
""")
# 3. The call
result = bimworks.FsApi(client).download_as_zip(request)
# 4. The result
with open("download-as-zip.zip", "wb") as file:
file.write(result)Check#
The downloaded original has the size the version record reports and opens in your IFC tool; uploading it again to the same folder is deduplicated and creates no new file (Upload a model). The converted file starts with a header that names IFC4 as its schema and the conversion in its description. The zip lists one entry per model with the folder structure of the tree.