mapteksdk.view.save_to_image module

Function for saving a view to an image file.

save_to_image(objects, path, overwrite=OverwriteMode.ERROR)

Save the given objects to an image file as they would be seen in a view.

The camera will either look top-down at the objects or from the front.

Objects may obstruct other objects. This means one or more of the objects provided may not be seen in the resulting image.

Parameters:
  • objects (Iterable[ObjectID | DataObject | str]) – The objects included in the image.

  • path (os.PathLike | str) – The path to where the image should be saved. This ideally should have a PNG extension.

  • overwrite (OverwriteMode) – How to handle writing an image to path if a file already exists there.

Returns:

The path of the resulting image.

Return type:

pathlib.Path

Raises:
  • ApplicationTooOldError – If you should use a newer version of the application as the feature is not available with the version connected to.

  • RuntimeError – If the view can not be opened.

  • NotADirectoryError – If the directory the image should be saved in does not exist or is not a directory.

  • FileExistsError – If overwrite is OverwriteMode.ERROR and path already exists.

  • OSError – If overwrite is OverwriteMode.OVERWRITE and path can’t be deleted.