3D Model

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

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

Bases: Base

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

Initialize a 3D Model instance.

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

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

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

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

Get a list of models with optional filtering and pagination.

Parameters:

api (GeoboxClient) – The GeoboxClient 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[Model] | int

Example

>>> from geobox import GeoboxClient
>>> from geobox.model3d import Model
>>> client = GeoboxClient()
>>> models = Model.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 = client.get_models(search="my_model",
...                           search_fields="name, description",
...                           order_by="name A",
...                           return_count=True,
...                           skip=0,
...                           limit=10,
...                           shared=False)
classmethod get_model(api, uuid, user_id=None)[source]

Get a model by its UUID.

Parameters:
  • api (GeoboxClient) – The GeoboxClient 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:

Model

Raises:

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

Example

>>> from geobox import GeoboxClient
>>> from geobox.model3d import Model
>>> client = GeoboxClient()
>>> model = Model.get_model(client, uuid="12345678-1234-5678-1234-567812345678")
or
>>> model = client.get_model(uuid="12345678-1234-5678-1234-567812345678")
classmethod get_model_by_name(api, name, user_id=None)[source]

Get a model by name

Parameters:
  • api (GeoboxClient) – The GeoboxClient 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:

Model | None

Example

>>> from geobox import GeoboxClient
>>> from geobox.model3d import Model
>>> client = GeoboxClient()
>>> model = Model.get_model_by_name(client, name='test')
or
>>> model = client.get_model_by_name(name='test')
update(**kwargs)[source]

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 import GeoboxClient
>>> from geobox.model3d import Model
>>> client = GeoboxClient()
>>> model = Model.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
...    }
... }
>>> model.update(name="new_name", description="new_description", settings=settings, thumbnail="new_thumbnail")
delete()[source]

Delete the model.

Returns:

None

Return type:

None

Example

>>> from geobox import GeoboxClient
>>> from geobox.model3d import Model
>>> client = GeoboxClient()
>>> model = Model.get_model(api=client, uuid="12345678-1234-5678-1234-567812345678")
>>> model.delete()
_create_progress_bar()[source]

Creates a progress bar for the task.

Return type:

tqdm

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

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 import GeoboxClient
>>> client = GeoboxClient()
>>> model = client.get_models()[0]
>>> model.download()
property thumbnail: str

Get the thumbnail URL of the model.

Returns:

The thumbnail of the model.

Return type:

str

Example

>>> from geobox import GeoboxClient
>>> from geobox.model3d import Model
>>> client = GeoboxClient()
>>> model = Model.get_model(api=client, uuid="12345678-1234-5678-1234-567812345678")
>>> model.thumbnail
share(users)[source]

Shares the model with specified users.

Parameters:

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

Returns:

None

Return type:

None

Example

>>> from geobox import GeoboxClient
>>> from geobox.model3d import Model
>>> client = GeoboxClient()
>>> model = Model.get_model(client, uuid="12345678-1234-5678-1234-567812345678")
>>> users = client.search_users(search='John')
>>> model.share(users=users)
unshare(users)[source]

Unshares the model with specified users.

Parameters:

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

Returns:

None

Return type:

None

Example

>>> from geobox import GeoboxClient
>>> from geobox.model3d import Model
>>> client = GeoboxClient()
>>> model = Model.get_model(client, uuid="12345678-1234-5678-1234-567812345678")
>>> users = client.search_users(search='John')
>>> model.unshare(users=users)
get_shared_users(search=None, skip=0, limit=10)[source]

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[User]

Example

>>> from geobox import GeoboxClient
>>> from geobox.model3d import Model
>>> client = GeoboxClient()
>>> model = Model.get_model(client, uuid="12345678-1234-5678-1234-567812345678")
>>> model.get_shared_users(search='John', skip=0, limit=10)