I have a Unstructured Grid VTK legacy file which is read using Python and the velocity calculated and stored as a Numpy array. I am looking to firstly export the array to its own VTK file for use in Paraview.
Your VTK_data
is, as the error said, a vtkFloatArray
. It does not have a GetOutput()
method and it cannot be written as an UnstructuredGrid.
You have to add your array to your dataset data
and then you can write data
with the writer:
VTK_data.SetName("VELOCITY")
data.GetPointData().AddArray(VTK_data)
writer = vtk.vtkUnstructuredGridWriter()
writer.SetFileName("Output.vtk")
writer.SetInputData(data)
writer.Update()
writer.Write()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.