[Paraview] ParaView scripting tutorial

Berk Geveci berk.geveci at kitware.com
Thu Mar 29 08:43:13 EST 2007


Hi folks,

There has been several questions about the scripting interface of
ParaView in the past. Hopefully the following excerpt from a message
to a Kitware support customer will answer some of those questions:

--- begin quote

The Tcl scripting in ParaView is limited to the GUI objects. You
cannot access underlying VTK objects directly through Tcl scripting.
What you need to do is to get the Tcl object for the appropriate GUI
object. To do this, start with the application singleton. You can
access this object using the $Application variable. To read about the
full API of this class, look at the doxygen documentation for
vtkPVApplication and vtkKWApplication here:
http://www.paraview.org/doc/nightly/html/classes.html

>From the application, you can get the main window with:
set mainWindow [$Application GetMainWindow]
(of class vtkPVWindow, inherits from vtkKWWindow)

You can also get the main view (the 3D view widget and associated
controls) with:
set mainView [$Application GetMainView]
(of class vtkPVRenderView, inherits from vtkKWView)

The main window stores pointers to all sources and filters. The GUI
elements for these objects are of type vtkPVSource. These are stored
in different groups. The group that stores the source and filters
created by the user is called Groups. You can get a collection of all
vtkPVSources in the group with:
set sourceList [$mainWindow GetSourceList Sources]

This returns an object of type vtkPVSourceCollection that inherits
from vtkCollection. You can get objects from it using
$sourceList GetNumberOfItems
$sourceList GetItemAsObject <index here>

GetItemAsObject will return a vtkPVSource. Once you have a
vtkPVSource, you can get to it's GUI object that controls the Display
tab with:
$pvSource GetPVOutput

This will return a vtkPVDisplayGUI. Look at the doxygen documentation
for vtkPVDisplayGUI to find the methods that control the actor.

You can also change the parameters of the source/filter using the
vtkPVSource object. Each property of the vtkPVSource object is
controlled by a vtkPVWidget. You can object the widget objects using
the GetPVWidget method:
$pvSource GetPVWidget <widget name>

The widget name needed for this method can be found by examining
Filters.xml in ParaView/GUI/Client/Resources in the ParaView source.
The name is determined by the trace_name attribute in the XML.

This is a just a short tutorial but should get you started. I will
also post this message to the ParaView mailing list so that other can
benefit from it.

-- end quote

Please note that this interface will become legacy once ParaView 3 is
release. ParaView 3 scripting API is completely different (and the
main scripting language is python although we can add tcl and java
support without too much effort in the future).

-- 
 Berk Geveci
 Kitware Inc.
 28 Corporate Drive
 Clifton Park, NY, 12065


More information about the ParaView mailing list