[Paraview] scripting beginner

Sebastien Jourdain sebastien.jourdain at kitware.com
Sat Feb 19 12:17:47 EST 2011


Hi,

you forget to call Render() before and after the ResetCamera().

Seb

On Sat, Feb 19, 2011 at 9:59 AM, Tim Gallagher <tim.gallagher at gatech.edu> wrote:
> Without looking at the script in detail, have you tried using the Python Trace feature in the GUI? Since, at this stage anyway, all of your tasks are straight forward, you can do them in the GUI with the trace turned on, then look at the resulting script to show you how all of it is done.
>
> That is, by far, the easiest way to learn how to script Paraview.
>
> Try the following script:
>
>  >from paraview.simple import *
>  >
>  >rv = GetRenderView() # Get a connection to the render window
>  >reader = OpenDataFile(PATH+'lfff00300000p_QC.vts')
>  >reader.Update() # Actually read the file in and update the pipeline
>  >contourFilter = Contour(reader)
>  >contourFilter.ContourBy = 'velocity'
>  >contourFilter.Isosurfaces = [0.0005, 0.001]
>  >dr = Show() # Update the pipeline again, but we need to alter how it looks
>  >lookupTable = CreateLookupTable( RBGPoints=[<minval to show>, 0.0, 0.0, 0.0, <maxval to show>, 1.0, 1.0, 1.0], VectorMode='Magnitude', ColorSpace='RGB', ScalarRangeInitialized=1.0) # This creates the color map, going from back to white
>  >dr.ColorArrayName = '<data array name to show>' # Tell it how you want contours colored
>  >dr.ColorAttributeType = '<POINT_DATA or CELL_DATA>' # Tell it the type of data it is coloring
>  >ResetCamera()
>  >WriteImage('picture.png')
>  >servermanager.SaveState('pythonstate.pvsm')
>
> That is something like what you need to do (I can't promise it works, but it will get you close -- I've never used a script with the Contour filter). Again, do what you are trying to do in the GUI with trace turned on and see what it outputs. You'll see some extra steps along the lines of what I added that should get you up and running.
>
> Tim
>
> ----- Original Message -----
> From: "Hartwig Anzt" <hartwig.anzt at kit.edu>
> To: paraview at paraview.org
> Sent: Saturday, February 19, 2011 9:15:35 AM
> Subject: [Paraview] scripting beginner
>
> Hi!
>
> I am real beginner in paraview scripting. Up to now, I used the paraview
> graphic platform, but since the tasks are getting more complex, I wanted
> to use paraview scripting with python.... and failed.
>
> What I want to do:
> - Load .vts-data
> - Create Contour
> - Set Data Range
> - Save State/Save Picture
>
> I wrote the following script:
>
>  >from paraview.simple import *
>  >
>  >reader = OpenDataFile(PATH+'lfff00300000p_QC.vts')
>  >contourFilter = Contour(reader)
>  >contourFilter.ContourBy = 'velocity'
>  >contourFilter.Isosurfaces = [0.0005, 0.001]
>  >Show(contourFilter)
>  >ResetCamera()
>  >WriteImage('picture.png')
>  >servermanager.SaveState('pythonstate.pvsm')
>
>
> If I run the script, two errors occur, probably with the same reason.
> The writer says:
> vtkSMRenderViewProxy (0x1e6da30): Disabling offscreen rendering since
> empty image was detected.
>
> When I open the state, there is nothing displayed. in order to see
> anything, I do have to press "Apply" for the Contour filter and "Reset"
> for the Camera, then everything looks fine.
>
> How can I implement, that these two operations are conducted?
>
> Thanks, Hartwig
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Karlsruhe Institute of Technology (KIT)
> Engineering Mathematics and Computing Lab (EMCL) &
> Institute for Applied and Numerical Mathematics 4
>
> Dipl.-Math. techn. Hartwig Anzt
> Research Associate
>
> Fritz-Erler-Str. 23, Geb. 01.86
> 76133 Karlsruhe, Germany
>
> Phone: +49 721 / 608 - 45849
> Email: hartwig.anzt at kit.edu
> Web:   http://numhpc.math.kit.edu, http://emcl.kit.edu,
>
> KIT - University of the State of Baden-Wuerttemberg and
> National Laboratory of the Helmholtz Association
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview
>


More information about the ParaView mailing list