Writing your own macro for STK's
Analyzer capability offers two main benefits:
• connecting you to all the parts of STK that haven't already been exposed via direct links (e.g., STK's Aviator and Radar capabilities)
• giving you the ability to add your own custom logic
There are four basic things that you need to do to create macros:
- Open the macro editor: Click the Macro Editor button in the main Analyzer window.
- Connect to the STK object model root: In any PreRun, PostRun, or other method, use the following line:
set root = app.getComponent("Model.STK").UserData - Create custom variables: In the comment lines above the Init() method, add a variable description:
' variable: MyCustomVariableName double input default=10000 description="custom variable description"
• You can describe both input and output variables as well as integer, double, etc.
• There are several examples and better explanations in the Analyzer help system.
- Get or set the value of your custom variables: In the PreRun(), PostRun(), or other methods, use app.getValue or app.setValue to get and set the variable values:
customVarValue = app.getValue("Model.STK.MyCustomVariableName")
• The path to get to a variable starts at the Model, then the STK application, and finally your MyCustomVariableName.
Hopefully, this article helps you get started with making your own custom macros. A very simple scenario that adjusts the altitude of a Coverage Definition based on a custom input variable for altitude (in feet) is attached to this article.