Getting Started

To use the Maptek Python SDK, you need to have the following essential components installed on your computer:

  • A Python interpreter. We recommend using Python for Workbench, which is available for download in Maptek Workbench.

  • The Maptek Python SDK. You can also download the SDK from Maptek Workbench.

  • A code editor to edit Python scripts. You can use any code editor to write Python, but we highly recommend using Visual Studio Code.

  • A compatible Maptek application. To run a script that interacts with your data in a Maptek project, the project must be open in a Maptek application instance. Compatible Maptek applications include Vulcan GeologyCore, PointStudio, and BlastLogic.

Installing Python and the Maptek Python SDK

The following steps will guide you through the process of installing Maptek Python SDK and configuring it for use in Maptek Workbench.

Step A: Install Python for Workbench.

Note:  You can skip this step if you intend to use an existing Python interpreter you have installed. The Python version must be compatible with the SDK. See Python SDK–interpreter compatibility on this page for more information.

To install Python for Workbench, follow these steps:

  1. In Maptek Workbench, open Download Manager.

  2. Navigate to WorkbenchShared ResourcesPython for Workbench.

    Tip:  To show Python for Workbench in Download Manager quickly, type python in the Filter field located at the top.

  3. Install the latest version of Python for Workbench.

Step B: Install Maptek Extend Wheels.

The Maptek Python SDK is part of the Maptek Extend Wheels package. To install the package:

  1. In Maptek Workbench, open Download Manager.

  2. Navigate to WorkbenchShared ResourcesExtend Wheels.

    Tip:  To show Extend Wheels in Download Manager quickly, type extend in the Filter field located at the top.

  3. Install the latest version of Extend Wheels.

Step C: Configure Python in Workbench.

After installing Python and the SDK, you need to configure Workbench to use them appropriately when running scripts. Follow these steps:

  1. Open Workbench Preferences by clicking the button in the Workbench title bar.

  2. Switch to the Python tab.

  3. Under Which Python do you want to use?, make sure the Python Installation radio button is selected, and select Python for Maptek Workbench from the drop-down.

  4. Under Which version of the Maptek Python SDK do you want to use?, make sure the latest version of the SDK appears in the Installed: field. If it is not, select the latest version from the Version: drop-down, and click Install.

  5. Check that the Python version is compatible with the SDK by clicking Check Installation.... A dialog will appear that confirms version compatibility and lists all the packages installed.

Installing and Configuring Visual Studio Code

Visual Studio Code is a source code editor that you can use to write, run, and debug Python code. We highly recommend using Visual Studio Code to initially develop Python scripts, but of course, other code editors can also be used.

Tip:  Getting Started with Python in VS Code on the Visual Studio Code website is a helpful tutorial to get you familiar with writing a basic Python script in Visual Studio Code.

To get started with Visual Studio Code, we recommend the following steps:

  1. Download Visual Studio Code from code.visualstudio.com and install.

  2. Install the Python extension for Visual Studio Code. This extension will enhance your Python scripting experience in Visual Studio by adding features such as IntelliSense and debugging.

  3. Select the appropriate Python interpreter. If you followed the steps in the previous section to install the Python for Workbench, this should be available for use in Visual Studio as the Python interpreter to use to run scripts.

    To select Python for Workbench as the interpreter, follow these steps:

    1. Open the command list by pressing Ctrl+Shift+P. Alternatively, navigate to Help > Show All Commands.

    2. In the command list, type >Python: Select Interpreter and select that command.

    3. In the list of interpreters that appear, select the interpreter that corresponds to the Python version installed with Python for Workbench. This is typically in a path that begins with C:\Program Files\Maptek\Extend\.

      FAQ

      Can I use an interpreter other than Python for Workbench?

      Yes, as long as the interpreter version is compatible with the version of the Maptek Python SDK you have installed (see Python SDK–interpreter compatibility on this page). If you don’t use Python for Workbench, you will need to install the Maptek Python SDK into your Python environment. To do this, you can run the command pip install mapteksdk.

Python SDK–interpreter compatibility

We recommend using Python for Workbench when getting started with the Maptek Python SDK. However, the SDK will work with other 64-bit CPython distributions such as those from Python.org and Anaconda. If you use a Python version other than Python for Workbench, it must be compatible with the SDK, as summarised by the following table:

Maptek Python SDK version Compatible Python versions
Extend Wheels 1.5 Python 3.7–3.11
Extend Wheels 1.4 Python 3.7, 3.8

Important:  Some Python implementations, such as IronPython and Jython, are not compatible with CPython. The SDK will not work with these implementations.

Writing your first script

Once you have your Python environment set up as described above, you should be ready to write your first script. Here’s an example script you can try to check that everything works as expected. The script will connect to a running Maptek application and display a message.

from mapteksdk.project import Project
from mapteksdk.operations import show_message

with Project() as project:
    show_message("Message", "Hello, world!")

Next topic: How to Run Python Scripts