[Paraview] Script for exporting multiple scenes

Ing. Claudio Pascarelli claudio.pascarelli at unisalento.it
Mon Oct 23 08:55:27 EDT 2017


Hi,

these are the first times that I'm using Paraview and Python.


I would like to create a script that:


1 - Read the number and name of properties (variables/contour plot) that I have in my .vtu file (for instance TEMPERATURE and TH_FLUX)

2 - Export every contour plot (Export Scenes) in vrml format, looping among them (like a "for" cycle), with the right name (for instance VtuName_TEMPERATURE.vrml and VtuName_TH_FLUX.vrml)


A priori I do not know how many and which are these properties so I think that I need first lo list them in some way.


If I record a trace this is what I obtain


***************************************************************************

#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()

# get active source.
valvola_XXX_termicovtu = GetActiveSource()

# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# uncomment following to set a specific view size
# renderView1.ViewSize = [763, 502]

# get display properties
valvola_XXX_termicovtuDisplay = GetDisplayProperties(valvola_XXX_termicovtu, view=renderView1)

# set scalar coloring
ColorBy(valvola_XXX_termicovtuDisplay, ('POINTS', 'TEMP'))

# rescale color and/or opacity maps used to include current data range
valvola_XXX_termicovtuDisplay.RescaleTransferFunctionToDataRange(True, False)

# show color bar/color legend
valvola_XXX_termicovtuDisplay.SetScalarBarVisibility(renderView1, True)

# get color transfer function/color map for 'TEMP'
tEMPLUT = GetColorTransferFunction('TEMP')

# export view
ExportView('C:/Users/User/Desktop/TEMP.vrml', view=renderView1)

# set scalar coloring
ColorBy(valvola_XXX_termicovtuDisplay, ('POINTS', 'TH_FLUX', 'Magnitude'))

# Hide the scalar bar for this color map if no visible data is colored by it.
HideScalarBarIfNotNeeded(tEMPLUT, renderView1)

# rescale color and/or opacity maps used to include current data range
valvola_XXX_termicovtuDisplay.RescaleTransferFunctionToDataRange(True, False)

# show color bar/color legend
valvola_XXX_termicovtuDisplay.SetScalarBarVisibility(renderView1, True)

# get color transfer function/color map for 'TH_FLUX'
tH_FLUXLUT = GetColorTransferFunction('TH_FLUX')

# export view
ExportView('C:/Users/User/Desktop/TH_FLUX.vrml', view=renderView1)

#### saving camera placements for all active views

# current camera placement for renderView1
renderView1.CameraPosition = [-0.09199999999789327, 0.0665, 0.7345691646101393]
renderView1.CameraFocalPoint = [-0.09199999999789327, 0.0665, -0.05375]
renderView1.CameraParallelScale = 0.2040320134204131

#### uncomment the following to render all views
# RenderAllViews()
# alternatively, if you want to write images, you can use SaveScreenshot(...).


*******************************************************


Thank you!!!!


Claudio Pascarelli


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20171023/0bb24ac4/attachment.html>


More information about the ParaView mailing list