Async 3D Model

The async Model3D module provides functionality for working with 3D Models.

class AsyncModel(api, uuid, data={})[source]

Bases: AsyncBase

Parameters:
BASE_ENDPOINT = '3dmodels/'
__init__(api, uuid, data={})[source]

Initialize a 3D Model instance.

Parameters:
  • api (AsyncGeoboxClient) – The AsyncGeoboxClient instance for making requests.

  • uuid (str) – The unique identifier for the model.

  • data (Dict, optional) – The data of the model.

async classmethod get_models(api, **kwargs)[source]

[async] Get a list of models with optional filtering and pagination.

Parameters:

api (AsyncGeoboxClient) – The AsyncGeoboxClient instance for making requests.

Keyword Arguments:
  • q (str) – query filter based on OGC CQL standard. e.g. “field1 LIKE ‘%GIS%’ AND created_at > ‘2021-01-01’”.

  • search (str) – search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.

  • search_fields (str) – comma separated list of fields for searching.

  • order_by (str) – comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: “A” denotes ascending order and “D” denotes descending order.

  • return_count (bool) – whether to return total count. default is False.

  • skip (int) – number of models to skip. default is 0.

  • limit (int) – maximum number of models to return. default is 10.

  • user_id (int) – specific user. privileges required.

  • shared (bool) – Whether to return shared models. default is False.

Returns:

A list of Model objects or the count number.

Return type:

List[AsyncModel] | int

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.model3d import AsyncModel
>>> async with AsyncgeoboxClient() as client:
>>>     models = await AsyncModel.get_models(api=client,
...                                     search="my_model",
...                                     search_fields="name, description",
...                                     order_by="name A",
...                                     return_count=True,
...                                     skip=0,
...                                     limit=10,
...                                     shared=False)
or
>>>     models = await client.get_models(search="my_model",
...                                     search_fields="name, description",
...                                     order_by="name A",
...                                     return_count=True,
...                                     skip=0,
...                                     limit=10,
...                                     shared=False)
async classmethod get_model(api, uuid, user_id=None)[source]

[async] Get a model by its UUID.

Parameters:
  • api (AsyncGeoboxClient) – The AsyncGeoboxClient instance for making requests.

  • uuid (str) – The UUID of the model to get.

  • user_id (int, optional) – Specific user. privileges required.

Returns:

The model object.

Return type:

AsyncModel

Raises:

NotFoundError – If the model with the specified UUID is not found.

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.model3d import AsyncModel
>>> async with AsyncgeoboxClient() as client:
>>>     model = await AsyncModel.get_model(client, uuid="12345678-1234-5678-1234-567812345678")
or
>>>     model = await client.get_model(uuid="12345678-1234-5678-1234-567812345678")
async classmethod get_model_by_name(api, name, user_id=None)[source]

[async] Get a model by name

Parameters:
  • api (AsyncGeoboxClient) – The AsyncGeoboxClient instance for making requests.

  • name (str) – the name of the model to get

  • user_id (int, optional) – specific user. privileges required.

Returns:

returns the model if a model matches the given name, else None

Return type:

AsyncModel | None

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.model3d import AsyncModel
>>> async with AsyncgeoboxClient() as client:
>>>     model = await AsyncModel.get_model_by_name(client, name='test')
or
>>>     model = await client.get_model_by_name(name='test')
async update(**kwargs)[source]

[async] Update the model’s properties.

Keyword Arguments:
  • name (str) – The new name for the model.

  • display_name (str) – The new display name.

  • description (str) – The new description for the model.

  • settings (Dict) – The new settings for the model.

  • thumbnail (str) – The new thumbnail for the model.

Returns:

The updated model data.

Return type:

Dict

Raises:

ValidationError – If the update data is invalid.

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.model3d import AsyncModel
>>> async with AsyncgeoboxClient() as client:
>>>     model = await AsyncModel.get_model(api=client, uuid="12345678-1234-5678-1234-567812345678")
>>>     settings = {
...        "model_settings": {
...        "scale": 0,
...        "rotation": [
...            0
...        ],
...        "location": [
...            0
...        ]
...        },
...        "view_settings": {
...        "center": [
...            0
...        ],
...        "zoom": 0,
...        "pitch": 0,
...        "bearing": 0
...        }
...     }
>>>     await model.update(name="new_name", description="new_description", settings=settings, thumbnail="new_thumbnail")
async delete()[source]

[async] Delete the model.

Returns:

None

Return type:

None

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.model3d import AsyncModel
>>> async with AsyncgeoboxClient() as client:
>>>     model = await AsyncModel.get_model(api=client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await model.delete()
_create_progress_bar()[source]

Creates a progress bar for the task.

Return type:

tqdm

async download(save_path=None, progress_bar=True)[source]

[async] Download the 3D model, save it as a .glb file, zip it, and return the zip file path.

Parameters:
  • save_path (str, optional) – Directory where the file should be saved.

  • progress_bar (bool, optional) – Whether to show a progress bar. Default: True

Returns:

Path to the .zip file containing the .glb model.

Return type:

str

Raises:

ApiRequestError – If the API request fails.

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> async with AsyncgeoboxClient() as client:
>>>     model = await client.get_models()[0]
>>>     await model.download()
property thumbnail: str

Get the thumbnail URL of the model.

Returns:

The thumbnail of the model.

Return type:

str

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.model3d import AsyncModel
>>> async with AsyncgeoboxClient() as client:
>>>     model = await AsyncModel.get_model(api=client, uuid="12345678-1234-5678-1234-567812345678")
>>>     model.thumbnail
async share(users)[source]

[async] Shares the model with specified users.

Parameters:

users (List[AsyncUsers]) – The list of user objects to share the model with.

Returns:

None

Return type:

None

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.model3d import AsyncModel
>>> async with AsyncgeoboxClient() as client:
>>>     model = await AsyncModel.get_model(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     users = await client.search_users(search='John')
>>>     await model.share(users=users)
async unshare(users)[source]

[async] Unshares the model with specified users.

Parameters:

users (List[AsyncUser]) – The list of user objects to unshare the model with.

Returns:

None

Return type:

None

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.model3d import AsyncModel
>>> async with AsyncgeoboxClient() as client:
>>>     model = await AsyncModel.get_model(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     users = await client.search_users(search='John')
>>>     await model.unshare(users=users)
async get_shared_users(search=None, skip=0, limit=10)[source]

[async] Retrieves the list of users the model is shared with.

Parameters:
  • search (str, optional) – The search query.

  • skip (int, optional) – The number of users to skip.

  • limit (int, optional) – The maximum number of users to retrieve.

Returns:

The list of shared users.

Return type:

List[AsyncUser]

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.model3d import AsyncModel
>>> async with AsyncgeoboxClient() as client:
>>>     model = await AsyncModel.get_model(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await model.get_shared_users(search='John', skip=0, limit=10)