Using CLI

From VisItusers.org

Jump to: navigation, search

VisIt's command line interface (or cli) is a Python-based, alternate interface to driving VisIt. This page gives the basics on using the cli.

Contents

[edit] Starting the CLI

There are two ways to start the CLI:

  • Invoke VisIt as "visit -cli"
  • Start up normally and start the CLI using the Window under Controls->Command.


[edit] Sourcing scripts

If you start VisIt directly from the command line, you can add "-s" with a script name, as in "visit -cli -s scriptname.py".

If you are already in the Python interpreter, you can call the function "Source("scriptname.py")"

[edit] Running entirely in batch

To run in batch, you start VisIt as "visit -cli -nowin -s scriptname.py". -nowin prevents the graphics window from appearing. If you run in batch, you must put the following lines into your script:

import sys
sys.exit()

Without these lines, the Python interpreter will try to read from the command line after executing your script. It will wait indefinitely for this input.

[edit] Learning the CLI

[edit] Manual

The python interface is documented here.

[edit] Examples

There are some example scripts here.

[edit] Inside the interpreter

You can list all functions using command "dir()". You can get help on any particular function with "help(function_name)". The help page has identical content to the Python manual.

[edit] Learning from the GUI

You can instruct VisIt to create Python scripts from your actions in the GUI. Go to Controls->Command and click "Record". Do work in the GUI and then click "Stop". The corresponding Python script will appear in the tab.

[edit] Special tips

[edit] Advanced features

  • You can set up your own buttons in the VisIt gui using the CLI. See here.
  • You can set up callbacks in the CLI that get called whenever events happen in VisiIt. See here.

[edit] Getting the attributes of existing plots and operators

For the case of having a single operator of a certain type applied to a plot, you get the operator's attributes by

t = TransformAttributes(1)
 
# Alternative method (coming in VisIt 1.9.0)
t = GetPlotOptions()

If you have more than one plot, don't forget to make the correct one active first! (SetActivePlot(0) for instance).

Currently, if you have more than one operator of the same type, the above will only give you the atts for the last operator of that type that was applied. However, VisIt 1.9.0 features a GetOperatorOptions function that can be used to return the operator attributes for the i'th operator applied to a plot.

# Assume that the session file contains a plot with a Reflect operator and 
# 2 Transform operators.
RestoreSession("foo.session",0)
 
# Get the operator attributes for each operator and print them
for opIndex in range(len(GetPlotList().GetPlots(0).operators)):
    atts = GetOperatorOptions(opIndex)
    print atts

To sum:

currentPlotAtts = PseudocolorAttributes(1)
defaultPlotAtts = PseudocolorAttributes()
 
currentOperatorAtts = SliceAttributes(1)
defaultOperatorAtts = SliceAttributes()

[edit] Determining the data members for attributes

You can see what the data member are for a set of attributes by instantiating it and then entering its name and pressing enter.

As in:

>>> t = SliceAttributes()
>>> t
originType = Intercept  # Point, Intercept, Percent, Zone, Node
originPoint = (0, 0, 0)
originIntercept = 0
originPercent = 0
originZone = 0
originNode = 0
normal = (0, -1, 0)
axisType = YAxis  # XAxis, YAxis, ZAxis, Arbitrary, ThetaPhi
upAxis = (0, 0, 1)
project2d = 1
interactive = 1
flip = 0
originZoneDomain = 0
originNodeDomain = 0
meshName = "default"
theta = 0
phi = 0
Personal tools