1

I have a vti file which contains certain geometry with hexagonal mesh. After a loading step a field variable name "concentration" changes and must be changed back zero. There is one possibility in paraview by hard way. Can any body share a way how to open, edit a field variable and overwrite a vti file with python. Thanks.

Ali_Sh
  • 2,667
  • 3
  • 43
  • 66

1 Answers1

2

You can use vtk python module to do that.

  1. read with vtkXMLImageDataReader
  2. Get the array to modify array = reader.GetOutput().GetCellData().GetArray("concentration")
  3. modify the array values by index: array.InsertTuple(i, 0)
  4. write back with vtkXMLImageDataWriter

See the read/write example

That is the native VTK solution. There is some other ways, as using numpy to modify the data array, or do it in ParaView python scripting

Nico Vuaille
  • 2,310
  • 1
  • 6
  • 14