[Paraview] Python scripting - displaying results on a FE mesh
Robert Cimrman
cimrman3 at ntc.zcu.cz
Mon Jun 16 12:04:39 EDT 2008
Hi,
I am trying to write a Python script to visualize a finite element mesh
with some fields, stored in a legacy VTK file (unstructured grid).
Following Servermanager2.pdf, I have created the script below, which
displays the mesh (solid color). However now I do not know how to
visualize one of the fields (point data or cell data), i.e. have some
colormap and related color bar. Does anyone have a small example script
to do that?
Then I digged more and found:
http://public.kitware.com/pipermail/paraview/2007-July/005394.html
The problem is that the script described there, that dumps the session
state from the paraview GUI into a python script, does not seem to work
with the Paraview 3.2. Is there an updated version somewhere?
best wishes,
--
Robert Cimrman
http://sfepy.org
-----
import sys
from paraview import servermanager
inFileName = sys.argv[1]
if not servermanager.ActiveConnection:
connection = servermanager.Connect()
if not connection:
raise exceptions.RuntimeError, 'Connection to localhost failed.'
print inFileName
reader = servermanager.sources.LegacyVTKFileReader( FileNames =
[inFileName] )
#reader.UpdateVTKObjects()
#reader.UpdatePipelineInformation()
print reader
view = servermanager.CreateRenderView()
rep = servermanager.CreateRepresentation(reader, view)
view.StillRender()
view.ResetCamera()
view.StillRender()
raw_input()
view.WriteImage("image.png", "vtkPNGWriter", 1)
More information about the ParaView
mailing list