Installing the SDK
The first step to using the Maptek Python SDK is to install and configure it. This will guide you through the process.
Installing Python
The Maptek Python SDK must be used in conjunction with the Python programming language. You can download Python from the Workbench Download Manager, or alternatively, from the Python Software Foundation.
In the Download Manager, Python is available under: Workbench > Shared Resources > Python for Workbench. Alternatively, type "Python" into the search bar to find it.
Note: You must be signed into Maptek Account on the Workbench to download and use the SDK.
Note: The Maptek Python SDK version 1.2 is built for compatibility with 64-bit (x86_64) installations of C Python and may not function correctly with Python distributions. Using this version of Python will provide the best experience with the SDK.
Note: Maptek recommends using Python 3.7, however version 1.2 is also compatible with Python 3.8
Installing the Extend Plugins
The Extend Plugins can be installed from the Workbench Download Manager. They can be found under Workbench/Shared Resources/Extend Plugins, or by typing “Extend” into the search bar.
Optional: Installing Visual Studio Code
There are many editors that can be used when writing python code. Maptek recommends using Microsoft’s Visual Studio Code for writing and debugging code.
Once Visual Studio Code has been installed, open it from the Start Page of the Workbench by clicking the icon under Tools.
By default, Visual Studio Code does not come with support for the Python programming language. However, the first time you open a Python file (A file with the .py extension) it will offer to install the Python Extension. This extension adds various useful options to Visual Studio Code, including syntax highlighting and options to run Python code within the code editor.
Note: When running Visual Studio Code, ensure that you are using the correct version of Python by selecting the option in the bottom left corner.
Configuration
The following steps need to be completed:
At times, you may need to update your SDK.
Select your Python Distribution
You should select which Python Distribution you want Workbench to use. Both the Extend Python Workflow component and Python scripts run from the Python tab in the ribbon will make use of this Python Distribution to run Python Scripts.
To select your desired Python Distribution, open Workbench Preferences, from the cog in the top right of the window.
Then, open the Python Preferences tab in the Workbench Preferences panel.
For most users, there will only be a single option (“Python for Maptek Workbench”), however advanced users may have several options (As shown in Figure 3 below).
Only Python installations that are compatible with the SDK will appear in the drop down box
Advanced users: The wheel for the Maptek Python SDK will be stored in %ProgramFiles%\Maptek\Extend\Plugins 1.0\wheels\ once downloaded and can be installed manually into Python environments not in the list by using (for example) python -m pip install “path/to/mapteksdk-1.0-cp37-cp37m-win_amd64.whl”
Select the version of the SDK
Next, you should select which version of the SDK you wish to use. Generally, you should select the highest version available in the drop down box as this version will have the most features available for use in scripts.
Install the SDK into the selected Python Environment
The final step is to make your selected version of the SDK available in your selected Python environment. To do this click the Check Installation button. This will open up the following window:
Click the Install button to install the SDK into your selected Python distribution. If the installation process completes successfully, you should see something similar to the following:
Updating the SDK
Maptek periodically releases newer versions of the SDK which include new features and bug fixes. To make use of new features, you will need to update to the newer version of the SDK. The following steps cover how to update the Maptek Python SDK to a new version.
- Install the newer version of the Extend Plugins using the Workbench Download Manager.
- (Optional): Uninstall the old version of the Extend Plugins. This will cause the old version to no longer appear in Python Preferences which will reduce the probability of accidentally choosing the wrong version of the SDK.
- In Python Preferences, choose the newer version of the SDK.
- Click Check Installation.
- Click the Update button next on the Check Python Installation panel.