When it comes to automating tasks in STK, Connect Commands stand out as an invaluable tool available to any STK Rocket Scientist! Whether you're conducting access reports for thousands of satellites with your ground sensor or loading satellites with updated databases daily using specific search filters, automation streamlines these processes. With tasks often becoming repetitive, STK Connect Commands offer the initial, straightforward step to mastering automation within STK. Moreover, the reasons for automating or integrating STK are numerous and diverse, ranging from needing specific calculation parameters like the cross-sectional area of a tumbling spacecraft to optimizing data collection schedules for ground stations. STK's rich API set enables the use of its powerful analytical engine within custom projects, facilitating tasks such as designing guidance laws for interceptor systems and conducting real-time and post-processing analysis.
STK Connect Commands represent the first step towards learning automation in STK. Indeed, even if you will use STK Object Model API, you will be able to execute Connect Commands with your script. In fact, most of the new STK features that come with the newest versions are often first implemented within Connect Commands before having their own Object Model definitions.
A great way to learn connect commands and test them is to use them directly inside of STK, without any implementation of any sort. You can use a simple tool called the HTML viewer in order to type in Connect command and execute them inside of your STK running instance. If you are a beginner with Connect command, this is a great way to understand their syntax and get familiar with how they affect your STK session.
Where can I find the Connect Commands Library?
The library can be viewed in different ways. You can search for Connect Commands with different filters, which the most important are:
Single commands sent to Connect use the following format:
<CommandName> <ObjectPath> [<CommandData>]
Where:
Important Notes:
You can find more information about Connect Commands Syntax here.
In complex projects, initial stages often involve experimentation, where the first part is built without full details for subsequent phases. Sometimes, significant changes lead to a crossroads: starting anew or revising existing work. This dilemma is common when constructing scenarios in STK.
A common example to such situation would be this one: you developed a scenario with a large satellite constellation, each with an onboard sensor initially set with default properties due to unknown specifications. As details emerged, you sought to edit sensor properties efficiently. While manually editing each sensor via the Properties Browser seemed tedious, it wasn't the sole option. STK offers various methods to modify groups of objects efficiently. Among them:
The wildcard character (*) can be used in an <InstanceName> in a Connect <ObjectPath>. The wildcard can only be used in the <ObjectPath> for which the command is being sent, it can not be used in an <ObjectPath> (or <TruncatedPath>) that is one of the command parameters, except where explicitly stated in a command's documentation.
The wildcard character can not be used in any <ObjectClass> name.
If the wildcard is used in a command returns data, the returned data for each object represented by the path, will be separated with a keyword, MDATA@DataLength@, where DataLength is the number of characters in the returned data for that object.
The wildcard should not be used with commands that write to a file. Only one file will be written and it will contain the data for the last path found.
When a command is entered using a wildcard in the <ObjectPath>, the path is expanded into all possible instances and the command is called for each instance. If any of the commands Nack, then a Nack will be returned, even though some commands may have completed successfully. To have the command ignore Nacks and continue processing use the ConControl / WildcardIgnoreNacksOn command.
*/Satellite/GPS*
The command with this path will affect all Satellites whose name begins with "GPS".
Scenario/stkDemo/Satellite/espSat/Sensor/*Test
The command with this path will affect all Sensors, on the Satellite espSat, whose name ends with "Test"
Scenario/stkDemo/Satellite/Sat*/Sensor/*
The command with this path will affect all Sensors on all Satellites whose name begins with "Sat".
*/Satellite/*/Sensor/*
The command with this path will affect all Sensors on all Satellites.
Chains */Constellation/ConstObj Add Place/*
The command adds all Place objects in the scenario to a Constellation object.
Chains */Constellation/ConstObj Add Place/*/Transmitter/*
The command adds all Transmitters on a Place object to a Constellation.
A simple connect command example for creating a new satellite on the current opened scenario's central body would be:
New / */Satellite MySatellite
Let's dig in this example and understand the structure behind this command.
The structure of a Connect Command is : <CommandName> <ObjectPath> [<CommandData>].
So our command name is New. If we look in the Alphabetical Listing of Connect Commands we will find that the command called "New" creates a new scenario or add a new object to the current scenario, and it will give us the following syntax rule:
You can easily find any information for a specific command and its parameters, syntax and special options in the Connect Command Library. Links displayed earlier in this article can lead you to the part of the library that you are most interested in. Each command listed in the library has a large description and explanation on the use of the command, as well as example commands.
STK has an embedded tool present natively called the Web Browser. It can help you to in turn open a natively present GUI that interacts with your current STK scenario and send and test Connect Commands through it.
In order to open the Web Browser, please select the View tab, and in the dropdown menu select Web Browser:
Once you click on the Web Browser, you should have a new window open with a search bar at the top and the web address of AGI Support loaded in. Near this search bar, you should be able to see a Folder Icon. Click on it:
Once you click on the Folder Icon, your File Explorer will be opened to select which file you want to open with the Web Browser. Make sure you are in the STK Branch (1), then click on the Example HTML Utilities folder (2) and double-click on the STK Automation folder (3):
Then select the Send a Connect Command folder:
Finally, double-click on the .htm file to open it in the STK Web Browser:
Here is the interface that should now be available inside of your STK Window:
Let's try our satellite example command!
You can now notice the new object in your component browser, but our satellite is not propagated so it is not visible in 3D yet. It just exists as a satellite object:
Let's use a more complicated command called "SetState" with the SGP4 propagator which you can find at this address.
Here, we will propagate our specific MySatellite satellite object (<SatObjectPath> is */Satellite/MySatellite) using the SGP4 propagator for the whole scenario duration interval (UseScenarioInterval {TimeInterval} argument of which you can find documentation on this page under the DATE/TIME OPTIONS title). We will use a 60 seconds <StepSize> parameter, and the NORAD number of the ISS (25544) for the <SSCNumber> parameter. Our TLESource parameter will be defined with the option Automatic. Which means it will be directly sourced from the default way, in our case, AGI Online Servers:
Here is a quick example of connect commands that actually builds the following items:
- ISS-like orbit: 420 km, 51.6° inclination (matches the real ISS)
- 3 ground stations at KSC, Baikonur, and Kourou/Guiana — the three primary ISS crew transport launch sites
- Each station has a wide-cone sensor (85° half-angle ≈ 5° elevation cutoff) auto-pointed at ISS
- Access windows computed for all 3 sites over 24 hours
- Access timing reports pop up for each station
|
# ── 1. CREATE SCENARIO ──────────────────────────────────────────────────── |
With the knowledge of Connect Commands at your disposal, you're ready to embark on experimentation within the STK GUI! Delve into the STK Connect Command Library, exploring new commands and honing your syntax skills. Additionally, leverage the HTML Utility as a straightforward automation tool for various STK tasks, from access calculations to EOIR. As you become proficient with Connect Commands, consider advancing to the Object Model API to develop more intricate automation scripts using languages like Python, C++, C#, Java, Visual Basic, Matlab, and beyond. Your journey into STK automation is just beginning!
Useful Links
Thanks,
Blacknight Space Team