Custom Labels in Analyzer

« Go Back

Information

 
QuestionHow do I define custom variable names in STK Analyzer?
Answer

Instructions

  1. Open the STK Analyzer Macro panel.
User-added image
Figure 1. STK Analyzer Macro panel
 
  1. 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.
User-added image
Figure 2. Init and PostRun Macro sections
 
  1. Add or remove the variables as needed, but keep sequential numbers at the end.
  2. Update the variables varName and str2 as needed, as well as the length of the "for" loop in the PostRun macro section.
  3. Click OK when you have finished.
  4. Run Analyzer as you normally would, except now use the custom variables for the outputs.
User-added image
Figure 3. Custom variables implemented
 
An example output graph:
User-added image
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
TitleCustom Labels in Analyzer
URL NameCustom-Labels-in-Analyzer

Related Files

LabelData.txt