Application Tasks

Of all possible externally generated tasks, this page addresses only general tasks pertaining to the Ansys Orbit Determination Tool Kit (ODTK®) application as a whole. It does not include any tasks concerning objects or attributes.

Use the following links for descriptions and code samples for these spcific tasks:

Connecting to the ODTK application

There are three common modes for interacting with the ODTK application. The final result of each of them is that they provide a handle to the root object in the ODTK application. Standard automation server properties are also available either to make the application invisible or to disable user control while the script is running. "ODTK.Application" refers to the most recently installed version of the ODTK application. Alternatively, you can specify a version number, such as "ODTK13.Application".

1. To start a new instance of the ODTK application:

COM

 

2. To attach to an already running instance of the ODTK application:

COM

 

3. To embed a script inside an HTML page and load that page into the ODTK Web Browser:

COM

Cross Platform API

Disconnecting from the ODTK application

To disconnect from the application, release all object handles in the order in which they were set. Then, unless you set UserControl=true, the application will shut down. If you want to immediately reopen the application, it may be necessary to "sleep" and allow the shutdown procedure to complete before opening another instance of the ODTK application, as shown in the following examples:

COM

Preference files

Access to user Preference files is optional.

Copy
odtk.release;
ePrefFiles_NoLoad_NoSave = 0,
ePrefFiles_Load_NoSave = 1,
ePrefFiles_Load_And_Save = 2

These control load the Application and User Preferences when Personality is loaded/initialized and saves the User Preference files upon exiting the application. User Preference files are usually found in user home/Documents/STK_ODTK 13/Config.

Example:

Copy
uiApp = CreateObject("ODTK13.Automation") // or "ODTK13.Engine"
uiApp.Visible = false
uiApp.UserControl - false
uiApp.PrefFilesMode = AgEPrefFilesMode.ePrefFiles_Load_No_Save
ODTK = uiApp.LoadPersonality("ODTK")
Note: This example is for ODTK 13. For other versions, change the version number.

The default value for ODTK13.Application and ODTK13.Automation is ePrefFiles_Load_And_Save, and the default mode for ODTK13.Engine is ePrefFile_Load_No_Save.

If you set the UserControl property to true, it enables saving of preference files, formats, and MRU file lists. A setting of "false" disables this, but still enables you interact with the application, though the ODTK application will not display any message boxes.

Setting a custom location for the ODTK log file

By default, the ODTK application will create its log in a user temp directory and delete it upon application exit. However, you may override this by using the following commands:

COM

Cross-Platform API

Using ODTK.WriteMessage() function

In addition to the application level uiApp.LogMsg() function common to all AGI products, the ODTK application implements an additional ODTK.WriteMessage() function. This provides the ability to generate messages from ODTK application-specific event handler scripts described below as well as adding more debugging functionality for scripts.

COM

Cross-Platform API

Closing child windows

You can access any of the windows in the ODTK application using the windows method. This will return a collection of all the open windows. The example below automatically closes all graph windows by checking the contents of their titles.

COM

Custom scripts for event handling

You can implement event handlers for the ODTK application in VBScript, Jscript, Python, and Perl. For example, Simulator.Events.OnComplete can be set to C:\Test\Test1.js file:

COM

The file extension determines which scripting engine is used and the file name itself determines which function inside the file is called to handle the event. The function receives two arguments: An error message for this event and the object originating this event.

You can access additional plugin point and scripting examples shipped with the ODTK application at <Install_Dir>\ODTK\AppData\Scripts.

For additional help, please refer to the ODTK Plugin Programming Guide.

Using external scripts to perform Date Time and Unit conversion

The ODTK application ships with a DataPicker Control that allows external scripts to perform Date, Time, and Unit conversions using the same rules and leap second awareness that is built into the ODTK application. Here are examples of using it in Javascript, VB Script, and Perl.

COM