[Paraview] ParaView python script - save pipeline data

Su, Simon M CTR USARMY ARL (US) simon.m.su.ctr at mail.mil
Tue Apr 29 13:52:42 EDT 2014


hello,

How do you write the output of the extract CTH parts filter to either pvd or vtk file format using python script? Using the PV GUI, the menu option save geometry will save the output to pvd formatted files.

I am using ParaView-4.1.0 on RHEL 5- 64bit (and RHEL 6 64bit). If I open PV and source a box, and then open up the Python Shell and to the following


>>> from paraview.simple import *

>>> writer=CreateWriter("/home/simonsm/filename.vtk")

>>> writer.UpdatePipeline()

>>>

it will create the filename.vtk file with the box in it.

However, in PV, using the GUI to load a CTH file and then apply the extract cth parts filters, and the do the following in the Python Shell,


>>> from paraview.simple import *

>>> writer=CreateWriter("/home/simonsm/filename.vtk")

>>> writer.UpdatePipeline()

>>>


I got the following


ERROR: In /home/utkarsh/Dashboards/MyTests/NightlyMaster/ParaViewSuperbuild-Release/paraview/src/paraview/ParaViewCore/ServerManager/Core/vtkSMWriterFactory.cxx, line 314

vtkSMWriterFactory (0x17ea2200): No matching writer found for extension: vtk


The same if I run the following script via pvpython (python script at the bottom of this email). It will create the image.png file but not filename.vtk file.

[bash]$ pvpython cth-trial1.py
ERROR: In /home/utkarsh/Dashboards/MyTests/NightlyMaster/ParaViewSuperbuild-Release/paraview/src/paraview/ParaViewCore/ServerManager/Core/vtkSMWriterFactory.cxx, line 314
vtkSMWriterFactory (0xab5acb0): No matching writer found for extension: vtk

Traceback (most recent call last):
  File "cth-trial1.py", line 47, in <module>
    writer.UpdatePipeline()
AttributeError: 'NoneType' object has no attribute 'UpdatePipeline'



============ python script cth-trial1.py ===========
try: paraview.simple
except: from paraview.simple import *
paraview.simple._DisableFirstRenderCameraReset()

spcth_0 = SpyPlotReader( FileName='spcth.0' )

AnimationScene1 = GetAnimationScene()
AnimationScene1.EndTime = 3.000620618747355e-05
AnimationScene1.PlayMode = 'Snap To TimeSteps'

spcth_0.CellArrays = ['Material volume fraction - 1']

RenderView1 = GetRenderView()
RenderView1.CenterOfRotation = [-2.44791666418314, -1.453125, 0.0]

DataRepresentation1 = Show()
DataRepresentation1.Representation = 'Outline'
DataRepresentation1.ScaleFactor = 0.6000000000000001
DataRepresentation1.EdgeColor = [0.0, 0.0, 0.5000076295109483]
DataRepresentation1.SelectionCellFieldDataArrayName = 'Material volume fraction - 1'

RenderView1.CameraPosition = [-2.44791666418314, -1.453125, 16.349424601301106]
RenderView1.CameraFocalPoint = [-2.44791666418314, -1.453125, 0.0]
RenderView1.CameraClippingRange = [10.215930355288094, 24.10966597032062]
RenderView1.CameraParallelScale = 4.231542463284413

ExtractCTHParts1 = ExtractCTHParts( ClipType="None" )

ExtractCTHParts1.ClipType = "None"
ExtractCTHParts1.VolumeArrays = ['Material volume fraction - 1']

DataRepresentation2 = Show()
DataRepresentation2.ScaleFactor = 0.10245815515518189
DataRepresentation2.SelectionPointFieldDataArrayName = 'Part Index'
DataRepresentation2.EdgeColor = [0.0, 0.0, 0.5000076295109483]
DataRepresentation2.SelectionCellFieldDataArrayName = 'Material volume fraction - 1'

DataRepresentation1.Visibility = 0

RenderView1.CameraClippingRange = [11.161534331537789, 23.636863982195774]

AnimationScene1.AnimationTime = 3.000620618747355e-05

Render()
WriteImage("image.png")
writer= CreateWriter("filename.vtk")
writer.UpdatePipeline()
=============================== end script =======================================

thank you
-simon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20140429/de0ce124/attachment.html>


More information about the ParaView mailing list