Scripting Overview

<< Previous: Other Catalog Files

Next: Scripting Functions >>

Cosmographia includes a Python-based scripting interface, providing access to many of the program’s elementary visualization functions and allowing users to create visualization sequences using these functions.
To access the program’s visualization functions scripts must import the Cosmographia scripting module, cosmoscripting, like this:
import cosmoscripting
cosmo = cosmoscripting.Cosmo()
cosmo.displayNote( "Hello world!", 3 )
The full set of available cosmoscripting functions and a realistic example script are provided in the Scripting Functions and Scripting Example sections of this guide.
Scripts can be started, re-started, and stopped using the following controls:
Run script
Shows a file dialog for selecting a script to be executed and immediately starts executing the script once it’s chosen.
Top Menu: Menu bar > File > Run Script
Command line: -p [script name]
Re-run recent
Re-start a recent script. One of the last five recently executed scripts can be re-started using the top menu option. The most recently executed script can be re-started using the keyboard shortcut.
Top Menu: Menu bar > File > Run Recent
Halt script
Stops execution of the currently running script.
Top Menu: Menu bar > File > Halt Script
Note the following important aspects of the scripting interface:
  • All of the program’s interactive controls are still available while a script is running. For example, mouse gestures can be used to move the camera and change its view directions. While on one hand this provides for a great deal of additional flexibility, on the other hand using such interactive controls when a script is running may interfere with the script’s visualization sequence and get it completely off track.
  • Because all scripting interface diagnostics, such as Python syntax errors or cosmoscripting function call errors, are printed to the standard error output, to see these diagnostics it is recommended to start the program from a terminal window, especially during script development and/or debugging activities. Note that many scripting functions generate a benign error “Trying to create a QVariant instance of QMetaType::Void type, an invalid QVariant will be constructed instead”. These errors can be ignored.
  • Only one script can be running at a time. If a script is running, the program will not start another script or re-start the running script until the running script is excplicitly stopped.