Instructions
- Open the STK Analyzer Macro panel.
Figure 1. STK Analyzer Macro panel
- Copy the example code, which is in a shaded region at the bottom of this article and also attached to this article in text file format. Paste it into the Init and PostRun Macro sections.
Figure 2. Init and PostRun Macro sections
- Add or remove the variables as needed, but keep sequential numbers at the end.
- Update the variables varName and str2 as needed, as well as the length of the "for" loop in the PostRun macro section.
- Click OK when you have finished.
- Run Analyzer as you normally would, except now use the custom variables for the outputs.
Figure 3. Custom variables implemented
An example output graph:
Figure 4. Example output graph
Custom Label Code
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copy and paste the following into the Init Macro section
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' THIS MACRO WILL BE EXECUTED FOR THE CURRENT STK SCENARIO
'
' Use this macro to create new variables and other initialization tasks.
'
'
' active=true
'
'variable: data1 double Output
'variable: data2 double Output
'
sub onInit()
' your code here
end sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copy and paste the following into the PostRun Macro section
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' THIS MACRO WILL BE EXECUTED FOR THE CURRENT STK SCENARIO
'
' Use this macro for any processing that needs to occur after each Scenario
' run has completed during a Trade Study.
'
'
' active=true
'
'
sub onPostRun()
' your code here
Dim varName, str1, str2
varName = "data"
For i = 1 To 2
str1 = "Model.STK." & varName & CStr(i)
str2 = "Model.STK.ScenarioName.Access.Satellite_Satellite1_Sensor_Sensor1_to_Place_Place" & CStr(i) & ".Access_Data.Duration.sum"
app.setvalue str1, app.getValue(str2)
'MsgBox str1
'MsgBox str2
Next
end sub