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.
Asked
Active
Viewed 339 times
1

Ali_Sh
- 2,667
- 3
- 43
- 66

Shahbaz Ahmed
- 45
- 3
1 Answers
2
You can use vtk
python module to do that.
- read with
vtkXMLImageDataReader
- Get the array to modify
array = reader.GetOutput().GetCellData().GetArray("concentration")
- modify the array values by index:
array.InsertTuple(i, 0)
- 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