Reference·Python SDK · bimworksPython

GISApi

Python SDK: the GIS - Geographic Information Systems operations, 6 methods, each with its parameters, result and a complete example.

Python SDK · bimworks · class · 6 methods

GIS related calls, for example to export to CityGML

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

MethodOperationDescription
copy_geo_referenceCopyGeoReferenceGive a Version the georeference of another
export_city_gml3ExportCityGML3Export one or more IFC models to CityGML 3 or CityJSON 2
extract_geo_referenceExtractGeoReferenceCompute a georeference from the model
generate3_d_tiles_urlGenerate3DTilesUrlCreate a signed 3D Tiles tileset URL for a folder or a set of versions
get_geo_referenceGetGeoReferenceRead or convert a georeference
set_geo_referenceSetGeoReferenceStore a Version's georeference

copy_geo_reference#

Python#
def copy_geo_reference(self, copy_geo_reference_request: CopyGeoReferenceRequest) -> CopiedGeoReference

Give a Version the georeference of another. Copies the georeference of from onto model: the latitude, longitude, elevation and rotation, rotation_north and original_epsg as they are, and the anchor point converted to the target's length unit, so it is the same point. A georeference places a Version's aligned coordinates, so a drawing (PDF, DWG) aligned onto an IFC model and given that model's georeference is shown on the earth where the model is: in GEO mode, next to GIS layers, on the map. The answer says where it came from (geo_reference_source, with the target's alignment at the time) and warns when the target has no alignment. Needs write rights on model and read rights on from.

OperationCopyGeoReference · POST /openapi/gis/CopyGeoReference
Scopegis:write

Parameters#

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

Returns#

CopiedGeoReference — The georeference as stored on model

Example#

Python#
import json

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.CopyGeoReferenceRequest.from_json(r"""
{
  "model": {
    "type": "UrlModelIdentifier"
  },
  "from": {
    "type": "UrlModelIdentifier"
  }
}
""")

# 3. The call
result = bimworks.GISApi(client).copy_geo_reference(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

export_city_gml3#

Python#
def export_city_gml3(self, export_city_gml3_request: ExportCityGML3Request) -> bytes

Export one or more IFC models to CityGML 3 or CityJSON 2. Export one or more IFC models into one city model, using per-LOD export settings that select objects and geometry via BQL. format chooses the encoding; it wins over the Accept header, which is only read when format is absent.

OperationExportCityGML3 · POST /openapi/gis/ExportCityGML3
Scopemodel:read

Parameters#

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

Returns#

bytes — The exported city model, in the requested format

Example#

Python#
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.ExportCityGML3Request.from_json(r"""
{
  "models": [
    {
      "type": "UrlModelIdentifier"
    }
  ],
  "settings": {},
  "format": "citygml3"
}
""")

# 3. The call
result = bimworks.GISApi(client).export_city_gml3(request)

# 4. The result
with open("export-city-gml3.gml", "wb") as file:
    file.write(result)

extract_geo_reference#

Python#
def extract_geo_reference(self, extract_geo_reference_request: ExtractGeoReferenceRequest) -> ExtractedGeoReference

Compute a georeference from the model. Computes a georeference from what the IFC file says, without storing it: call SetGeoReference with the answer to keep it. method:

OperationExtractGeoReference · POST /openapi/gis/ExtractGeoReference
Scopegis:read

Parameters#

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

Returns#

ExtractedGeoReference — The georeference that was found

Example#

Python#
import json

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.ExtractGeoReferenceRequest.from_json(r"""
{
  "model": {
    "type": "UrlModelIdentifier"
  },
  "method": "map_conversion",
  "epsg": "",
  "wkt": ""
}
""")

# 3. The call
result = bimworks.GISApi(client).extract_geo_reference(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

generate3_d_tiles_url#

Python#
def generate3_d_tiles_url(self, generate3_d_tiles_url_request: Generate3DTilesUrlRequest) -> Generate3DTilesUrl200Response

Create a signed 3D Tiles tileset URL for a folder or a set of versions. Mints a URL to a Cesium 3D Tiles tileset.json of the models of a folder node (followed recursively at request time) or of a fixed set of versions. The settings — which objects, in which colours, with which batch-table columns — are signed into the URL and cannot be changed by whoever holds it. The URL is valid for 90 days.

OperationGenerate3DTilesUrl · POST /openapi/gis/Generate3DTilesUrl
Scopegeometry:read

Parameters#

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

Returns#

Generate3DTilesUrl200Response — The tileset URL

Example#

Python#
import json

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.Generate3DTilesUrlRequest.from_json(r"""
{
  "node_uuid": "00000000-0000-0000-0000-000000000000",
  "version_uuids": [
    "<version uuid of the first demo model>"
  ],
  "settings": {},
  "link_account": false
}
""")

# 3. The call
result = bimworks.GISApi(client).generate3_d_tiles_url(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

get_geo_reference#

Python#
def get_geo_reference(self, get_geo_reference_request: Optional[GetGeoReferenceRequest] = None) -> GeoReferenceResult

Read or convert a georeference. With model: the georeference stored on the Version (null when it has none), in target_epsg, with its anchor point in model coordinates, the grid convergence and how its rotation is measured (rotation_north). include_map_conversion adds what the model's own IfcMapConversion says, for a comparison.

OperationGetGeoReference · POST /openapi/gis/GetGeoReference
Scopegis:read

Parameters#

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

Returns#

GeoReferenceResult — The georeference

Example#

Python#
import json

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.GetGeoReferenceRequest.from_json(r"""
{
  "model": {
    "type": "UrlModelIdentifier"
  },
  "geo_reference": {},
  "target_epsg": "EPSG:4326",
  "include_map_conversion": false,
  "include_source": false
}
""")

# 3. The call
result = bimworks.GISApi(client).get_geo_reference(request)

# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))

set_geo_reference#

Python#
def set_geo_reference(self, set_geo_reference_request: SetGeoReferenceRequest) -> None

Store a Version's georeference. Stores where the model is on earth: the georeference (a point in a coordinate system with a rotation) and the anchor point in model coordinates that it applies to. rotation_north says whether the rotation is to grid north (GRID) or true north (TRUE); without it the rotation is to grid north of original_epsg when there is one, else to true north. Needs write rights on the Version. To compute one from the model first, see ExtractGeoReference.

OperationSetGeoReference · POST /openapi/gis/SetGeoReference
Scopegis:write

Parameters#

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

Returns#

Nothing: the operation answers without a body (Stored).

Example#

Python#
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.SetGeoReferenceRequest.from_json(r"""
{
  "model": {
    "type": "UrlModelIdentifier"
  },
  "geo_reference": {},
  "anchor_point": {
    "x": 0.0,
    "y": 0.0,
    "z": 0.0
  },
  "rotation_north": "GRID",
  "original_epsg": ""
}
""")

# 3. The call
bimworks.GISApi(client).set_geo_reference(request)

# 4. The result
# (SetGeoReference answers no content: the call returns once it succeeded and throws a bimworks.ApiException otherwise)
print("Done")