[Paraview] Script for exporting multiple scenes
Utkarsh Ayachit
utkarsh.ayachit at kitware.com
Thu Oct 26 22:46:04 EDT 2017
Claudio,
Attached is an example script with a demo vtu file used for it.
Hope that helps.
Utkarsh
On Mon, Oct 23, 2017 at 8:55 AM, Ing. Claudio Pascarelli <
claudio.pascarelli at unisalento.it> wrote:
> 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
>
>
>
>
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20171026/ecd718b3/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.vtu.tar.gz
Type: application/x-gzip
Size: 97155 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/paraview/attachments/20171026/ecd718b3/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: script.py
Type: text/x-python
Size: 684 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/paraview/attachments/20171026/ecd718b3/attachment.py>
More information about the ParaView
mailing list