[Paraview] Saving a slice of data for later visualization

Tim Gallagher tim.gallagher at gatech.edu
Mon Oct 26 20:21:25 EDT 2015


Hi,

I'm struggling to write a script for Paraview that will let me take a slice through my vtkMultiblockDataSet and save just the slice (so all of the data on the slice and all of the points that make up the slice) in a format that I can look at later. I can get it to dump all of the data to a set of CSV files, but I can't look at those again in paraview. 

My function is very simple (see below). I have tried to use CreateWriter directly with the .vtk file extension like is shown on http://www.paraview.org/Wiki/ParaView/Python_Scripting#Writing_Data_Files_.28ParaView_3.9_or_later.29 but that says the vtk file format is unknown and so it doesn't work. 

I have tried virtually every writer that would make sense in that writer line and none of them work properly. As it is, the one that is there now says:

vtkCompositeDataPipeline (0x9ac9380): Can not execute simple alorithm without output ports

and I don't know what that means or why it fails to write. (Side note -- algorithm is spelled wrong in that error message, comes from vtkCompositeDataPipeline.cxx line 168).

Anybody have any suggestions or advice on how to save the datasets that results from a slice so I can look at just that slice later?

Thanks,

Tim

def run(out_dir, file_num, spreadsheet_name, slice_origin, slice_normal, triangulate=False):
    restart_file = XDMFReader(FileName=out_dir+'/RESTS/rest_%05i.xmf' % file_num)
    restart_file_dr = Show()

    if triangulate:
        tri = 1
    else:
        tri = 0

    my_slice = Slice(SliceOffsetValues=[0.0], Triangulatetheslice=tri, SliceType="Plane" )
    my_slice.SliceType.Origin = slice_origin
    my_slice.SliceType.Normal = slice_normal

    slice_dr = Show()

    writer = XMLUnstructuredGridWriter(Input=my_slice)
    writer.FileName = out_dir+"/post/"+"%s_data_%05i_.vtu" % (spreadsheet_name, file_num)
    writer.UpdatePipeline()


More information about the ParaView mailing list