[Paraview] Script for exporting multiple scenes

claudio.pascarelli at unisalento.it claudio.pascarelli at unisalento.it
Tue Nov 14 04:10:47 EST 2017


Dear Utkarsh,
sorry for the delay. Thank you very much for your help.
With minor changes the code seems working very well. However the lines:

# load all available point and cell arrays.
reader.PointArrayStatus.SelectAll()
reader.CellArrayStatus.SelectAll()

seems to usefull if not followed by the "Apply" command. As I noticed, the
two lines only check the relevant chekboxes. How can I simulate the
"Apply" button?

Also, what does

display.RescaleTransferFunctionToDataRange()

really do?

Last but not least, do you know a way to also export the chromatic scale
(legend) associated to each ContourPlot? I can't do it even manually.

Best regards

Claudio

P.S. Here attached the files you sent me.





> 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 --------------
A non-text attachment was scrubbed...
Name: foo.vtu
Type: application/octet-stream
Size: 274442 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/paraview/attachments/20171114/829114d0/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: script.py
Type: application/octet-stream
Size: 673 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/paraview/attachments/20171114/829114d0/attachment-0003.obj>


More information about the ParaView mailing list