0

I am using Paraview with the Python Shell and I want to modify some coordinates. The considered data is opened using a reader, the new coordinates are saved just as txt. I obtain the grid from the reader by using the Fetch()-routine and then modify it -- but my question is: can I somehow "return" the now changed grid to the reader-object and then Show() it?

Here is the code used so far:

from paraview import simple
from paraview.vtk import *
import numpy as np

reader=simple.LSDynaReader(FileName='/home/test.d3plot')
reader.UpdatePipeline()
simple.Show(reader)

coord=np.loadtxt('/home/coord.dat')

pts=vtkPoints()
arr=vtkFloatArray()
arr.SetNumberOfComponents(3)

arr.SetVoidArray(coord,14766*3,1)
ug=vtkUnstructuredGrid()

#the data to be modified is a vtkUnstrucuredGrid in a vtkMultiBlockDataset
ug.ShallowCopy(simple.servermanager.Fetch(reader).GetBlock(84))
pts.SetData(arr)
ug.SetPoints(pts)

How can I make the changes visible now? Any help would be appreciated!

lu_siyah
  • 305
  • 1
  • 3
  • 9

2 Answers2

1

ParaView is not designed for this and hence doesn't provide mechanisms to do exactly that. If you want to transform data in Python, look at using the Programmable Filter (http://www.paraview.org/Wiki/Python_Programmable_Filter) instead.

Utkarsh
  • 1,407
  • 1
  • 11
  • 19
  • So just to understand it correctly -- it is not possible to access these nice mechanisms of the programmable filter via external Python script / PVPython? – lu_siyah Jan 06 '14 at 09:52
  • No, they are, but you will have to create the programmable filter in the Python script and pass another "script" to it do the work. – Utkarsh Jan 08 '14 at 05:17
0

I am bit late but I found this question while looking for my own How to add a custom array to a polydata in paraview? . I ended up exporting the data as csv with numpy.savetxt and reading the new csv again

Community
  • 1
  • 1
lib
  • 2,660
  • 2
  • 25
  • 49