mapteksdk.context_menu module
Module for scripts run from context menus.
Workbench customisation can be used to add Python Scripts to context menus. This module contains functions designed for scripts run from context menus.
- exception NoContextInformationError
Bases:
RuntimeError
Exception raised when the context menu information does not exist.
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception InvalidContextInformationError
Bases:
ValueError
Error raised when the context menu information is invalid.
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- context_location()
The location of the mouse pointer when the context menu was opened.
Typically this will be a point on the context object. This can be any point on the object and often will not correspond with any of the points in the points property of the context object.
- Returns
Numpy array of the form [X, Y, Z] representing the location of the mouse.
- Return type
numpy.ndarray
- Raises
NoContextInformationError – If the script was not run from a context menu or there were no compatible objects under the mouse when the context menu was opened.
InvalidContextInformationError – If the context location could not be parsed. This typically indicates a version mismatch.
- context_object_path()
The path to the context object in the Project.
This can be passed to Project.edit() or Project.read() to open the context object.
- Returns
The path to the object the mouse was over when the context menu was opened.
- Return type
str
- Raises
NoContextInformationError – If the script was not run from a context menu or there were no compatible objects under the mouse when the context menu was opened.
- context_object_id()
The object ID of the context object in the Project.
Unlike context_object_path(), this will fail if the script is not connected to an application. This can be passed to Project.edit() or Project.read() to read the context object.
- Returns
The object ID of the object the mouse was over when the context menu was opened.
- Return type
- Raises
NoContextInformationError – If the script was not run from a context menu or there were no compatible objects under the mouse when the context menu was opened.
InvalidContextInformationError – If the context object could not be found.
NoConnectedApplicationError – If this function is called when the script is not connected to an application.