Automation Samples

To automate repetitive tasks in STK, you can use HTML, Connect, and STK Objects to build tools that are accessible from within STK. Otherwise, drive STK remotely using tools, like the Button Tool or the COM Interface, or use a command line or batch file to send Connect commands to STK.

Sample project files are in Visual Studio 2019, Visual Studio 2017, and Visual Studio 2022 formats. All files names contain "_VS2019", "_VS2017", or "_VS2022", indicating the format type.

Using the Code Samples

The code samples included in the STK install are read only. To work with any of the installed code samples:

  1. From the Windows Start menu, select STK 12->STK Codesamples 12 or to access <STK install folder>/CodeSamples/CodeSamples.zip.
  2. Copy CodeSamples.zip to a folder where you have write permissions and unzip the file.
  3. Change the properties of the files to writable before compiling them.

All code samples for automating STK, listed below, are organized by programming language and project name in the <user-selected folder>CodeSamples/Automation//<Language>/<Project> folder.

Language Project Description
C++ AccessReport Shows the basics of how to access Interfaces and work with some of the more difficult types, such as VARIANT_BOOL, VARIANT and SAFEARRAY*.
Connect Shows how to use basic Connect operations to establish a connection to STK, send Connect commands to STK, and retrieve data from STK.
Language Project Description
C# AccessConstraints Shows how to bring up the STK UI and modify the access constraints on a satellite.
AreaTarget Configures an AreaTarget's characteristics via the Object Model in a running STK instance.
Aviator This example demonstrates how to use the STK Aviator API via the Object Model in a running STK instance.
Events Shows how to use the events generated in the STK UI.
Scenario Show how to use and modify the scenario properties in the UI.
STK Tutorial Shows how to set up a typical STK scenario using the Object Model and the STK UI.
UnitPreferences Displays the Unit Preferences characteristics in a running STK instance.
ConnectToSpecificSTKInstance Shows how to connect to a specific instance of STK.
Language Project Description
Java

For instructions on configuring the Java samples with the Eclipse IDE, click here.

Automation_Swing_STK Based project used by all other Automation_Swing_STK_* samples for configuration necessary for AWT/Swing based applications. This project does not provide any runnable sample.
Automation_Swing_STK_Basic Creates a Java application process that uses the STK Java API to connect to and programmatically drive/automate an external STK Application process. The connection mechanism uses process to process shared memory communication, not TCP/IP.
Automation_Swing_STK_CustomApp_Integration Creates a Java application process that uses the STK Java API to connect to and programmatically drive/automate an external STK Application process as well as then import a facility object to the embeded (in-process) STK Engine Runtime. The connection mechanism to the STK UI process uses process to process shared memory communication, not TCP/IP. The connection mechanism to the embedded STK Engine Runtime used direct Java to Native method calls in process.
Automation_Swing_STK_Plugin_AccessConstraint_Config Configures and uses the "Extend_STK_Plugin_AccessConstraint_Config" Java plugin sample via STK Automation connection.
Automation_Swing_STK_Plugin_AccessConstraint_NIIRS Configures and uses the "Extend_STK_Plugin_AccessConstraint_NIIRS" Java plugin sample via STK Automation connection.
Automation_Swing_STK_Plugin_AccessConstraint_Range Configures and uses the "Extend_STK_Plugin_AccessConstraint_Range" Java plugin sample via STK Automation connection.
Automation_Swing_STK_Root_Events Creates a Java application process that uses the STK Java API to connect to and programmatically drive/automate an external STK Application process as well as show that event notification can be configured (i.e., turned on or off) to improve performance of the STK UI the application is connected to by not marshaling event information (like animation events) from process to process.
Automation_SWT_STK Based project used by all other Automation_SWT_STK_* samples for configuration for SWT based applications. This project does not provide any runnable sample.
Automation_SWT_STK_Aviator This example demonstrates how to use the STK Aviator API in a automation application.
StkConnect_Socket Shows how to use StkCon.java to connect to a running instance of STK through a socket connection and send Connect commands.
Language Project Description
MATLABAnalysisWorkbench_ObjectModel Creates a variety of vector, time, and calculation components through Object Model.
Astrogator_ObjectModel Walks through the basic functions of the Astrogator object model by building the "Hohmann Transfer Using a Targeter" tutorial, found in the STK help.
Aviator_ObjectModel_CarrierLanding Creates a scenario that uses Aviator to fly an aircraft through Navy carrier landing operations.
Aviator_ObjectModel_FuelConsumptionStudy Walks through the basics of using MATLAB with Aviator by flying a route from JFK to LAX at various altitudes and comparing the fuel consumption. Additonally, the tutorial uses the Advanced Fixed Wing Tool by creating an aircraft performance model that uses a high bypass turbofan engine.
Comm_ConnectCommands Creates a scenario to demonstrate communications and uses Connect commands to build up a transmitter and receiver by changing their definition properties.
Coverage_ObjectModel This is an example of how to use MATLAB to create a scenario, add a satellite, add constraints, and compute revisit time for that satellite with Coverage. Additionally, this uses the Grid Inspector tool.
LifetimeTool This example builds a satellite and then configures the Lifetime Tool through Connect commands and returns the date of decay, number of orbits, and days until deorbit.
STK_Automation_Tutorial This is a complete example of the "Using MATLAB for STK Automation" tutorial that additionally points the sensor to the closest target in the collection and generates a graph in MATLAB of the results.
Language Project Description
Python Aviator_ObjectModel_CarrierLanding.py Creates a scenario that uses Aviator to fly an aircraft through Navy carrier landing operations.
Aviator_ObjectModel_FuelConsumptionStudy.py Walks through the basics of using MATLAB with Aviator by flying a route from JFK to LAX at various altitudes and comparing the fuel consumption. Additonally, the tutorial uses the Advanced Fixed Wing Tool by creating an aircraft performance model that uses a high bypass turbofan engine.
HohmannTransferUsingTargeter.py Walks through the basic functions of the Astrogator object model by building the "Hohmann Transfer Using a Targeter" tutorial, found in the STK help.
STKProTutorial.py Shows how to set up a typical STK scenario using the STK object model.
Language Project Description
Perl ConnectExample Shows how to use the Stk.pm file to communicate with STK via Connect.