OpenDX Documentation
Full Contents QuickStart Guide User's Guide User's Reference
Previous Page Next Page Table of Contents Partial Table of Contents Index Search

3.9 Scripting Language

Sometimes it may be more convenient to use the Data Explorer scripting language instead of the Visual Program Editor to create visualizations. A common instance is that of using Data Explorer scripts in overnight batch jobs to create visualizations and save them to disk for analysis the next day.

A simple script that computes a series of isosurfaces and exports them to disk is /usr/lpp/dx/samples/tutorial/batch_script (this is not a visual program, so you cannot read it into the Visual Program Editor):

data = Import("/usr/lpp/dx/samples/data/watermolecule");
counter = 1;
macro create_iso(isovalue,counter)->(counter)
{
  isosurface = Isosurface(data,isovalue);
  filename = Format("iso%d", counter);
  counter++;
  Export(isosurface, filename);
}
(continued on the next page)
counter=create_iso(0.1, counter);
counter=create_iso(0.2, counter);
counter=create_iso(0.3, counter);
counter=create_iso(0.4, counter);
counter=create_iso(0.5, counter);
counter=create_iso(0.6, counter);
# (end of script)
This script first imports data from a file called watermolecule. It then defines a macro that takes two parameters: an isovalue and a counter. The macro returns the counter as an output. It then computes an isosurface, creates a filename (using the counter as part of the name), and exports the isosurface to that filename. The counter is also incremented. Finally the macro is called six times, with six different isovalues.

To run this script, first copy /usr/lpp/dx/samples/tutorial/batch_script to the directory being used. Then enter the command:

    dx -script < batch_script
or
    dx -script
and at the dx> prompt:
    include "batch_script"

If you want to view the exported isosurfaces, you can use visual program /usr/lpp/dx/samples/tutorial/view_isosurfaces.net.

Note: Visual programs are also scripts. However, if a visual program uses a macro, you must include that macro before including the visual program. For example:

dx> include "my_macro.net"
dx> include "program.net"


Full Contents QuickStart Guide User's Guide User's Reference

[ OpenDX Home at IBM | OpenDX.org ]