STK ObjectsSend comments on this topic.
IAgStkObjectRoot Interface

Description

Represents the automation interface supported by the root object of the Automation Object Model.

Public Methods

Public Method AllInstanceNamesToXMLReturns an XML representation of AllInstanceNames.
Public Method BeginUpdateSignals the object that the batch update is starting. This should only be called when manipulating graphical properties of objects that already exist. Never create or destroy objects or call Avtr methods inside Begin/End update blocks.
Public Method CloseScenarioCloses the scenario. The method throws an exception if no scenario has been loaded.
Public Method EndUpdateSignals the object that the batch update is complete. This should only be called when manipulating graphical properties of objects that already exist. Never create or destroy objects or call Avtr methods inside Begin/End update blocks.
Public Method ExecuteCommandExecutes a custom CONNECT action. The method throws an exception if the command has failed.
Public Method ExecuteMultipleCommands Executes multiple CONNECT actions. The behavior of the method when encountering an exception varies depending on the setting of the Action parameter. See the help for AgEExecMultiCmdResultAction.
Public Method GetLicensingReportReturns a formatted string that contains the license names and their states. The string is formatted as an XML document.
Public Method GetObjectFromPathGets the object instance that matches the path provided
Public Method Isolate

Mutually isolates unit preference settings in the current instance from those in other instances of the root.

Public Method LoadLoads a scenario/vdf using the specified path. The method throws an exception if there is a scenario already loaded.
Public Method LoadCustomMarkerAdds a custom marker to Application
Public Method LoadScenarioUse Load method. Loads a scenario using the specified path. The method throws an exception if there is a scenario already loaded.
Public Method LoadVDFLoads a vdf using the specified path. The method throws an exception if there is a scenario already loaded. If the password isn't needed, enter an empty string.
Public Method LoadVDFFromSDFLoads a vdf from SDF using the specified path. The method throws an exception if there is a scenario already loaded. If the password isn't needed, enter an empty string.
Public Method LoadVDFFromSDFWithVersionLoads a vdf from SDF using the specified path. The method throws an exception if there is a scenario already loaded. If the password isn't needed, enter an empty string.
Public Method NewScenarioCreates a new scenario. User must close a scenario before creating a new one; otherwise an exception will occur.
Public Method ObjectExistsChecks whether a currently loaded scenario contains an object with the given path.
Public Method SaveSaves the changes made to the scenario/vdf.
Public Method SaveAsSaves the changes made to the scenario/vdf to a specified path and file name.
Public Method SaveScenarioUse Save method. Saves the changes made to the scenario.
Public Method SaveScenarioAsUse SaveAs method. Saves the changes made to the scenario to a specified path and file name.
Public Method SaveVDFAsSaves the changes made to the scenario to a specified path and file name as a vdf file.
Public Method SaveVDFToSDFSaves a vdf to SDF at the specified location. The method throws an exception if the VDF creation or upload fails.

Public Properties

Public Property AvailableFeaturesAllows the user to inquiry about the available features
Public Property CentralBodiesReturns a collection of available central bodies.
Public Property ConversionUtilityReturns the conversion utility interface.
Public Property CurrentScenarioReturns a Scenario object or null if no scenario has been loaded yet.
Public Property IsolatedReturns whether the instance is isolated.
Public Property NotificationFilter
Public Property StdMil2525bSymbolsReturns the interface that enables creating 2525b symbols
Public Property StkPreferencesConfigures STK preferences.
Public Property UnitPreferencesProvides access to the Global Unit table.
Public Property VgtRootReturns an instance of VGT root object.

Interfaces

CoClasses that Implement IAgStkObjectRoot

Example

Load a VDF
[C#]
// Pass an empty string if there is no password to the VDF.
root.LoadVDF(vdfPath, vdfPassword);
Load a VDF
[Visual Basic .NET]
' Pass an empty string if there is no password to the VDF.
root.LoadVDF(vdfPath, vdfPassword)
Start STK Engine and get a reference to IAgStkObjectRoot
[Python - STK API]
# Start new instance of STK Engine
from agi.stk12.stkengine import STKEngine

stk = STKEngine.StartApplication(noGraphics=False) # optionally, noGraphics = True

# Get the IAgStkObjectRoot interface
root = stk.NewObjectRoot()

Get a reference to IAgStkObjectRoot using a running STK instance
[Python - STK API]
# Get reference to running STK instance
from agi.stk12.stkdesktop import STKDesktop

stk = STKDesktop.AttachToApplication()

# Get the IAgStkObjectRoot interface
root = stk.Root

Start STK and get a reference to IAgStkObjectRoot
[Python - STK API]
# Start new instance of STK
from agi.stk12.stkdesktop import STKDesktop

stk = STKDesktop.StartApplication(visible=True) #using optional visible argument

# Get the IAgStkObjectRoot interface
root = stk.Root

Open a VDF
[Python - STK API]
# IAgStkObjectRoot root: STK Object Model Root
root.LoadVDF(r'C:\Program Files\AGI\STK 12\Data\ExampleScenarios\Intro_STK_Space_Systems.vdf', '')

Close an open Scenario
[Python - STK API]
# IAgStkObjectRoot root: STK Object Model Root
root.CloseScenario()

Create a new Scenario
[Python - STK API]
# IAgStkObjectRoot root: STK Object Model Root
root.NewScenario('Example_Scenario')

Set unit preferences for Object Model
[Python - STK API]
# IAgStkObjectRoot root: STK Object Model Root
root.UnitPreferences.Item('DateFormat').SetCurrentUnit('UTCG')
root.UnitPreferences.Item('Distance').SetCurrentUnit('km')

Execute Connect command
[Python - STK API]
root.ExecuteCommand('New / */Target MyTarget')

Execute multiple Connect commands
[Python - STK API]
commandList = [['New / */Place MyPlace'], ['SetPosition */Place/MyPlace Geodetic 37.9 -75.5 0.0']]
root.ExecuteMultipleCommands(commandList, AgEExecMultiCmdResultAction.eExceptionOnError)

Extract data from Connect result
[Python - STK API]
result = root.ExecuteCommand('Report_RM */Place/MyPlace Style "Cartesian Position"')

for i in range(0, result.Count):
    cmdRes = result.Item(i)
    print(cmdRes)

Start STK and get a reference to IAgStkObjectRoot
[MATLAB]
% Create an instance of STK
uiApplication = actxserver('STK12.Application');
uiApplication.Visible = 1;

% Get our IAgStkObjectRoot interface
root = uiApplication.Personality2;


        
Create instance of AgStkObjectRoot in STK Engine application
[MATLAB]
% Before instantiating AgStkObjectRoot an instance of AgSTKXApplication or an STK X control must be created
% This also requires a STKX license to be present
STKXApplication = actxserver('STKX12.Application');
rootEngine = actxserver('AgStkObjects12.AgStkObjectRoot');


        
Open a VDF
[MATLAB]
% IAgStkObjectRoot root: STK Object Model Root
root.LoadVDF('C:\Program Files\AGI\STK 12\Data\ExampleScenarios\Intro_STK_Space_Systems.vdf', '');


        
Close an open Scenario
[MATLAB]
% IAgStkObjectRoot root: STK Object Model Root
if ~isempty(root.CurrentScenario)
    root.CloseScenario();
end


        
Close STK
[MATLAB]
% AgUiApplication uiApplication: STK Application
uiApplication.Quit;
clear uiApplication root


        
Get a reference to the AgStkObjectRoot using the running STK instance
[MATLAB]
% Get reference to running STK instance
uiApplication = actxGetRunningServer('STK12.Application');

% Get our IAgStkObjectRoot interface
root = uiApplication.Personality2;


        
Create a new Scenario
[MATLAB]
% IAgStkObjectRoot root: STK Object Model Root
root.NewScenario('Example_Scenario');


        
STK window layout settings
[MATLAB]
% AgUiApplication uiApplication: STK Application
% Loop through the available windows to close the Timeline and maximize the
% 3D window
timelineWindow = '';
for i=0:uiApplication.Windows.Count - 1
    window = uiApplication.Windows.Item(i);
    if (strcmp(window.Caption, '3D Graphics 1 - Earth'))
        window.WindowState = 'eWindowStateMaximized';
    elseif (strcmp(window.Caption, ''))
        timelineWindow = window;
    end
end
timelineWindow.Close();


        
Set unit preferences for Object Model
[MATLAB]
% IAgStkObjectRoot root: STK Object Model Root
root.UnitPreferences.Item('DateFormat').SetCurrentUnit('UTCG');
root.UnitPreferences.Item('Distance').SetCurrentUnit('km');


        
Execute Connect command
[MATLAB]
root.ExecuteCommand('New / */Target MyTarget');


        
Execute multiple Connect commands
[MATLAB]
commandList = {'New / */Place MyPlace';'SetPosition */Place/MyPlace Geodetic 37.9 -75.5 0.0'};
root.ExecuteMultipleCommands(commandList, 'eExceptionOnError');


        
Extract data from Connect result
[MATLAB]
result = root.ExecuteCommand('Report_RM */Place/MyPlace Style "Cartesian Position"');

for i = 0:result.Count-1
    cmdRes = result.Item(i);
    fprintf(' %s \n', cmdRes);
end


        
© 2024 Analytical Graphics, Inc. All Rights Reserved.