Report Output Properties

Use the Report Output properties page to control how STK processes a static or dynamic display report for output, including formatting options.

Display

You can define the Point Size of the report text and the colors used to display the report. Select Use Default to use system default colors or select the Foreground (text) and Background colors that you want to use by clicking on the drop-down menus.

Post Processing

You can control the format and processing of a static report with a script. Click the button to specify the location of the script that you want to use. The script will automatically apply for the current report type. Select Use Same Script For All Report Types to have STK apply the script for all report types rather than just the currently selected one. Use the Delete Selection button to remove a previously selected script.

Once you have selected a script, click the Report Type drop-down menu to select the type of output that will run the script:

  • Display: Display the report to the screen.
  • Print: Print the report to the default printer.
  • File Save: Save the file in ASCII text format.
  • File Export: Export the report.

About post-processing scripts

You can use any scripting or programming language that can be called from a system command to create a post-processing script. The script is called from a system command that passes the path to the temp file containing the generated report as an argument. The script runs on this temp file and then returns control to STK, which delivers the report using the destination method that you have selected for it.

The most common uses for post-processing scripts are:

  • Custom Formatting - An example of this is creating a custom date/time format or merging sections.
  • External Actions or Events - An example of this is automatically emailing the report upon creation.

You cannot use a post-processing script to connect back to STK (using either Connect or the Object Model) because the report creation holds the process and must run to completion before returning control to STK.

Example Scripts

You can expand any of the toggled sections below to review an example script and an explanation of its purpose. The first example shows several versions of the same script, while the other examples are all Perl scripts.

Simple Line Numbers

This basic script adds line numbers to the report before displaying it. The script is presented in Perl, Python, VBScript, and Windows Batch File formats.

ViewClosed

Perl

#
# this is the temp file used by STK
#
$inputfile = shift;

#
# open/read/close the file
#
open (INPUT, "$inputfile");
@inData = <INPUT>;
close INPUT;

#
# open the new file (overwite input file) for writing
#
open (OUTPUT, ">$inputfile");
$count = 1;
foreach (@inData){
	# do something with the data
	print OUTPUT $count++ . " " . $_;
	}

#
# close the output file
#
close OUTPUT;

#
# when the script ends, STK will disply whatever is in the $inputfile
#
exit;

Python#

#
# this is the temp file used by STK
#
import sys
inputfile = sys.argv[1]

#
# open/read the file
#
content = []
with open(inputfile) as f:
    content = f.readlines() 
    
#
# open the new file (overwite input file) for writing
#
outfile = open (inputfile, 'w')
count = 1
for s in content:
	outfile.write (str(count) + " " + s),
	count += 1

#
# close the output file
#
outfile.close()

VBScript

Set objFSO = CreateObject("Scripting.FileSystemObject") 

'
' this is the temp file used by STK
'
inputfile = WScript.Arguments.Item(0)

'
' open/read/close the file
'
Set objFile = objFSO.OpenTextFile(inputfile, 1)
Dim inData()
i = 0
Do Until objFile.AtEndOfStream
	Redim Preserve inData(i)
	inData(i) = objFile.ReadLine
	i = i + 1
Loop
objFile.Close

'
' open the new file (overwite input file) for writing
'
i = 1
Set objFile = objFSO.CreateTextFile(inputfile, 1)
For Each line in inData
	' do something with the data
	objFile.Write i & " " & line & vbCrLf
	i = i + 1
Next

'
' close the output file
'
objFile.Close

'
' when the script ends, STK will disply whatever is in the inputfile
'

Windows Batch File

echo off

REM
REM this is the temp file used by STK
REM
set inputfile=%1   
set inputfile=%inputfile:"=%

REM
REM create temp file
REM
set tmpfile=%1".tmp"
echo % >> %tmpfile%

REM
REM loop through input file - pushing edits to output file
REM
set x=1
setlocal EnableDelayedExpansion
for /f "delims=|" %%i in (%inputfile%) do (
	echo !x! %%i >> %tmpfile%
	set /a x=!x!+1
	)

REM
REM replace input with temp file
REM
copy /A %tmpfile% %inputfile%

REM
REM delete temp file
REM
del %tmpfile%

Access/AER to Ephemeris

This script uses the default Access/AER report to create an external ephemeris file of the ‘To’ object, using the ‘From’ object as a custom coordinate system.

ViewClosed

$inputfile = shift;

#
# open/read/close the file
#
open (INPUT, "$inputfile");
@IN = <INPUT>;
close INPUT;

#
# open the new file (same as input file) for writing
#
open (OUTPUT, ">$inputfile");

my @data;
my $fromObj;

foreach (@IN){
	chomp;
	
	if (($_ =~ /^\s*(.*)-To-/) && (! $fromObj)){
		$fromObj = $1;
		$fromObj =~ s/\-/\//;
		}
	
	# pattern match to pull out 4 adjacent numbers (time/el/az/range)
	# time (epsecs), elevation(degs), azimuth (degs), range (meters)
	if ($_ =~ /^\s*(\d*\.{0,1}\d*)\s+(\d*\.{0,1}\d*)\s+(\d*\.{0,1}\d*)\s+(\d*\.{0,1}\d*)$/){
		push (@data, "\t" . $1 . "\t-" . $2 . "\t" . $3 . "\t" . $4);
		}
	}

print OUTPUT "stk.v.4.3\n\n";
print OUTPUT "BEGIN Ephemeris\n\n";
print OUTPUT "NumberOfEphemerisPoints " . $#data . "\n";
print OUTPUT "\#ScenarioEpoch\n";
print OUTPUT "InterpolationMethod     Lagrange\n";
print OUTPUT "InterpolationOrder      1\n";
print OUTPUT "DistanceUnit            meters\n";
print OUTPUT "CentralBody             Earth\n";
print OUTPUT "CoordinateSystem        Custom Body " . $fromObj . "\n\n";
print OUTPUT "EphemerisLLRTimePos\n";
print OUTPUT join ("\n", @data);

SSC Number to Common Name

This script, when assigned to a DeckAccess report that was computed to a Satellite Deck, will replace the SSC number with the common name as listed in the %ProgramData%\AGI\STK 13\Databases\Satellite\stkSatDbAll.sd file.

ViewClosed

#
# this is the temp file used by STK.
#
$inputfile = shift;

#
# read the file into memory
#
open (IN, "$inputfile");
@data = <IN>;
close IN;

#
# find stkSatDbAll.sd
#
$sd = $ENV{'ProgramData'} . "\\AGI\\STK 13\\Databases\\Satellite\\stkSatDbAll.sd";

#
# open .sd file, create a hash of tle-common names
#
if (-e $sd){
	open (SD, $sd);
	foreach (<SD>){
		$satSD{substr($_,0,5)} = substr($_,5,15);
		}
	close (SD);
	}

else {
	$sd = "";
	}

#
# open the file for writing (this is what STK will display)
#
open (OUTPUT, ">$inputfile");

if ($sd){
	print OUTPUT "SSC numbers have been replaced with common names from\n$sd file\n\n";
	}
else{
	print OUTPUT "Unable to find %ProgramData%\\AGI\\STK 13\\Databases\\Satellite\\stkSatDbAll.sd file.\n\n";
	}

foreach (@data){
	if ($sd){
		s/       Start Time/                 Start Time/;
		s/^-----    -/---------------    -/;
		s/^(\d{5})/$satSD{$1}/;
		}
	print OUTPUT "$_";
	}

#
# close the output file
#
close OUTPUT;

#
# when the script ends, STK will disply whatever is in the $inputfile
#
exit;

LLA Position Data to STK Waypoint (*.ga) File

This script will create an STK-formatted Waypoint File (*.ga) from LLA data.

ViewClosed

use Date::Calc qw( Delta_DHMS check_date check_time);

#
# this is the temp file used by STK.
#
$inputfile = shift;

%month_to_num = (
	  'Jan',  '1', 
	  'Feb',  '2', 
	  'Mar',  '3', 
	  'Apr',  '4', 
	  'May',  '5', 
	  'Jun',  '6', 
	  'Jul',  '7', 
	  'Aug',  '8', 
	  'Sep',  '9', 
	  'Oct', '10',
	  'Nov', '11',
	  'Dec', '12',
	  );

#
# open/read/close the file
#
open (INPUT, "$inputfile");
@inData = <INPUT>;
close INPUT;


#
# open the new file (same as input file) for writing
#
open (OUTPUT, ">$inputfile");

print OUTPUT "stk.v.7.0\n";
print OUTPUT "BEGIN GreatArc\n";
print OUTPUT "Method DetVelFromTime\n";
$time_of_first_waypoint = get_time_of_first_waypoint();
print OUTPUT "TimeOfFirstWaypoint " . $time_of_first_waypoint . "\n";
print OUTPUT "NumberOfWaypoints " . get_num_of_points() . "\n";
print OUTPUT "BEGIN Waypoints\n";

($ed, $em, $ey, $eh, $emin, $es) = split (/[\s+:]/,$time_of_first_waypoint);


foreach (@inData){
	chomp;
	($d, $m, $y, $time, $lat, $lon, $alt) = split (/\s+/);
	($h, $min, $s) = split (/:/,$time);
	
	if ((check_date($y,$month_to_num{$m},$d))&& (check_time($h,$min,$s))){
		($D,$H,$M,$S) = Delta_DHMS($ey,$month_to_num{$em},$ed, $eh,$emin,$es, $y,$month_to_num{$m},$d, $h,$min,$s); 
		$sec = ((((($D * 2 ) * $H) * 60 ) + $M) * 60 ) + ($s - $es);
		print OUTPUT "\n\t$sec \t $lat \t $lon \t $alt \t 0 \t 0";
		}
	}

print OUTPUT "\n\nEND Waypoints\n";
print OUTPUT "END GreatArc\n";

#
# close the output file
#
close OUTPUT;

#
# when the script ends, STK will disply whatever is in the $inputfile
#
exit;

sub get_time_of_first_waypoint {
	my ($time, $count, $d, $m, $y, $h, $min, $s);
	$count = 0;
	while (! $time){
		($d, $m, $y, $h, $min, $s) = split (/[\s:]/,$inData[$count++]);
		if ((check_date($y,$month_to_num{$m},$d))&& (check_time($h,$min,$s))){
			$time = "$d $m $y $h:$min:$s";
			}
		}
	return ($time);
	}

sub get_num_of_points {
	my ($count, $d, $m, $y, $h, $min, $s, $numpoints);
	$count = 0;
	$numpoints = 0;
	foreach (@inData){
		($d, $m, $y, $h, $min, $s) = split (/[\s:]/,$inData[$count++]);
		if ((check_date($y,$month_to_num{$m},$d))&& (check_time($h,$min,$s))){
			$numpoints++;
			}
		}
	return ($numpoints);
	}