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.pascare...@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 > >
foo.vtu.tar.gz
Description: GNU Zip compressed data
from paraview.simple import * reader = OpenDataFile('/tmp/foo.vtu') # load all available point and cell arrays. reader.PointArrayStatus.SelectAll() reader.CellArrayStatus.SelectAll() display = Show() for (arrayName, arrayInfo) in reader.PointData.items(): # color by array of interest ColorBy(display, ("POINTS", arrayName)) # in case we want to force LUT range to match data. display.RescaleTransferFunctionToDataRange() # render Render() fname = "/tmp/points_%s.vrml" if raw_input("Save as '%s'? (y/n) " %fname) in ['y', 'Y']: ExportView(fname) # do the same for cell data, if needed by iterating over items in `reader.CellData.items()`
_______________________________________________ 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