STK AstrogatorSend comments on this topic.
IAgVAScriptingTool Interface

Description

Properties for the Scripting Tool.

Public Methods

Public Method CopyToClipboardCopies entire scripting tool to clipboard.
Public Method PasteFromClipboardReplaces entire scripting tool with scripting tool in clipboard.
Public Method ScriptTextInjects the script into the scripting tool.

Public Properties

Public Property CalcObjectsReturns the collection of the calculation objects.
Public Property EnableIf true, the scripting tool is enabled.
Public Property LanguageTypeGets or sets the scripting language being used.
Public Property ParametersReturns the collection of parameters.
Public Property PreIterateIf true, the sequence will run once before executing the script.
Public Property SegmentPropertiesReturns the collection of the segment properties.

Interfaces

Implemented Interface

CoClasses that Implement IAgVAScriptingTool

Example

Configure sequence segment with scripting tool
[C#]
// Add launch sequence and retrieve the 
IAgVAMCSSegment segment = driver.MainSequence.Insert(AgEVASegmentType.eVASegmentTypeSequence, "MySequence", "-");
IAgVAMCSSequence sequence = segment as IAgVAMCSSequence;

IAgVAScriptingTool scriptTool = sequence.ScriptingTool;
scriptTool.Enable = true;
scriptTool.LanguageType = AgEVALanguage.eVALanguageVBScript;
scriptTool.ScriptText(
@"
DeltaArg = dArg

REM  Set the optimizers desired results
DEOdArgUB = DeltaArg
DEOdArgLB = DeltaArg


REM  Initial guess tool:
REM  Assume transfer orbit is something like a circular orbit linking apoapse of initial orbit to apoapse of final orbit
REM  Constants: 
mu = 398600
pi = 3.14159265358979

REM  Step 1:  propagate to apoapsis
Prop1Dur = Period_0/2

REM  Step 2:  conditions at end of initial orbit:
SMA_0 = 0.5*(RadApo_0 + RadPeri_0)
VelApo_0 = sqr( (RadPeri_0*mu) / (RadApo_0*SMA_0) )

REM  Step 3:  evaluate properties of the circular transfer orbit
Rcirc = RadApo_0
Vcirc = sqr(mu/Rcirc)
PeriodCirc = 2*pi*Sqr( Rcirc*Rcirc*Rcirc / mu)

REM  Step 4:  set first maneuver to enter transfer orbit
Burn1X = Vcirc - VelApo_0
Burn1Z = 0

REM  Step 5:  propagate along transfer orbit the desired change in argument of periapse
If DeltaArg >= 0 Then
 TransferDur = PeriodCirc*(DeltaArg/360)
Else 
 TransferDur = PeriodCirc*(360+DeltaArg)/360
End If

REM Step 6:  set second maneuver to enter desired final orbit
Burn2X = -Burn1X
Burn2Z = 0
");

// Configure the script tool's segments

IAgVAScriptingSegment burn1X = scriptTool.SegmentProperties.Add("Burn1X");

if (Array.IndexOf(burn1X.AvailableObjectNames, "Optimize_Delta_w.Burn1") != -1)
{
    burn1X.ObjectName = "Optimize_Delta_w.Burn1";
    burn1X.Attribute = "ImpulsiveMnvr.Cartesian.X";
    burn1X.Unit = "km/sec";
}

IAgVAScriptingCalcObject period0 = scriptTool.CalcObjects.Add("Period_0");
period0.CalcObjectName = "Segments/Value At Segment";
IAgVAStateCalcValueAtSegment valAtSeg = period0.CalcObject as IAgVAStateCalcValueAtSegment;
valAtSeg.CalcObjectName = "Keplerian Elems/Orbit Period";
Configure sequence segment with scripting tool
[Visual Basic .NET]
' Add launch sequence and retrieve the 
Dim segment As IAgVAMCSSegment = driver.MainSequence.Insert(AgEVASegmentType.eVASegmentTypeSequence, "MySequence", "-")
Dim sequence As IAgVAMCSSequence = TryCast(segment, IAgVAMCSSequence)

Dim scriptTool As IAgVAScriptingTool = sequence.ScriptingTool
scriptTool.Enable = True
scriptTool.LanguageType = AgEVALanguage.eVALanguageVBScript
scriptTool.ScriptText(vbCr & vbLf & "            DeltaArg = dArg" & vbCr & vbLf & vbCr & vbLf & "            REM  Set the optimizers desired results" & vbCr & vbLf & "            DEOdArgUB = DeltaArg" & vbCr & vbLf & "            DEOdArgLB = DeltaArg" & vbCr & vbLf & vbCr & vbLf & vbCr & vbLf & "            REM  Initial guess tool:" & vbCr & vbLf & "            REM  Assume transfer orbit is something like a circular orbit linking apoapse of initial orbit to apoapse of final orbit" & vbCr & vbLf & "            REM  Constants: " & vbCr & vbLf & "            mu = 398600" & vbCr & vbLf & "            pi = 3.14159265358979" & vbCr & vbLf & vbCr & vbLf & "            REM  Step 1:  propagate to apoapsis" & vbCr & vbLf & "            Prop1Dur = Period_0/2" & vbCr & vbLf & vbCr & vbLf & "            REM  Step 2:  conditions at end of initial orbit:" & vbCr & vbLf & "            SMA_0 = 0.5*(RadApo_0 + RadPeri_0)" & vbCr & vbLf & "            VelApo_0 = sqr( (RadPeri_0*mu) / (RadApo_0*SMA_0) )" & vbCr & vbLf & vbCr & vbLf & "            REM  Step 3:  evaluate properties of the circular transfer orbit" & vbCr & vbLf & "            Rcirc = RadApo_0" & vbCr & vbLf & "            Vcirc = sqr(mu/Rcirc)" & vbCr & vbLf & "            PeriodCirc = 2*pi*Sqr( Rcirc*Rcirc*Rcirc / mu)" & vbCr & vbLf & vbCr & vbLf & "            REM  Step 4:  set first maneuver to enter transfer orbit" & vbCr & vbLf & "            Burn1X = Vcirc - VelApo_0" & vbCr & vbLf & "            Burn1Z = 0" & vbCr & vbLf & vbCr & vbLf & "            REM  Step 5:  propagate along transfer orbit the desired change in argument of periapse" & vbCr & vbLf & "            If DeltaArg >= 0 Then" & vbCr & vbLf & "             TransferDur = PeriodCirc*(DeltaArg/360)" & vbCr & vbLf & "            Else " & vbCr & vbLf & "             TransferDur = PeriodCirc*(360+DeltaArg)/360" & vbCr & vbLf & "            End If" & vbCr & vbLf & vbCr & vbLf & "            REM Step 6:  set second maneuver to enter desired final orbit" & vbCr & vbLf & "            Burn2X = -Burn1X" & vbCr & vbLf & "            Burn2Z = 0" & vbCr & vbLf & "            ")

' Configure the script tool's segments

Dim burn1X As IAgVAScriptingSegment = scriptTool.SegmentProperties.Add("Burn1X")

If Array.IndexOf(burn1X.AvailableObjectNames, "Optimize_Delta_w.Burn1") <> -1 Then
	burn1X.ObjectName = "Optimize_Delta_w.Burn1"
	burn1X.Attribute = "ImpulsiveMnvr.Cartesian.X"
	burn1X.Unit = "km/sec"
End If

Dim period0 As IAgVAScriptingCalcObject = scriptTool.CalcObjects.Add("Period_0")
period0.CalcObjectName = "Segments/Value At Segment"
Dim valAtSeg As IAgVAStateCalcValueAtSegment = TryCast(period0.CalcObject, IAgVAStateCalcValueAtSegment)
valAtSeg.CalcObjectName = "Keplerian Elems/Orbit Period"
© 2024 Analytical Graphics, Inc. All Rights Reserved.