Getting Started with the STK Python API
About the STK Python API
Historically interacting with STK Desktop and STK Engine from Python has been achieved using the win32com or comtypes Python modules. While these methods still work and are still supported, the STK Python API offers the following advantages:
-
Cross-platform support: Code written using the new API interacting with STK Engine can be used on Windows and on Linux without modifications, assuming the usual cross platform Python guidelines are followed.
-
Usability improvements:
- STK object model types have built-in support for the Python help function.
- The new API provides definitions for all enumerations. With win32com, enumerations had to be defined manually based on the corresponding numerical value.
- Better IDE support through type hints (based on the typing module).
Prerequisites
The instructions in this section assume that you have a working Python environment on your machine. Python version3.6 or greater is required.
Install the Wheel file
The STK Python API is packaged as a wheel file that can be installed using pip. The wheel file is included with the STK install in the bin/AgPythonAPI directory.
Verify the installation
The final step to ensure a working development setup is to run a simple program that exercises the API. In a Python file, copy and paste the code below and run it. Everything is set up for developing applications with STK.
[Python - STK API] | ||
---|---|---|
|
This will print the version of STK currently installed on your machine.
Next steps
Once you have completed the installation, refer to the Programmer’s Guide as needed. If you have existing Python scripts using win32com or comtypes, refer to the Migration Guide.