set/get FieldData with numpy_interface.dataset_adapter
Hello, I am doing experiments, trying to set and get FieldData on e.g. a PolyData, UnstructuredGrid, etc., with numpy_interface.dataset_adapter. I am particularity interested in string FieldData, used to store various attributed of a vtk object, but also in numeric arrays.
However if I try to use the same syntax as for Points, I always get errors.
import vtk from vtk.numpy_interface import dataset_adapter as dsa import numpy as np my_polydata = vtk.vtkPolyData() # add some points and cells to my_polydata here.. my_polydata_dsa = dsa.WrapDataObject(my_polydata) # set string example my_polydata_dsa.FieldData["key_1"] = "string_1" >>> TypeError: 'DataSetAttributes' object does not support item assignment # numeric example my_polydata_dsa.FieldData["key_2"] = [1.0, 2.0, 3.0] >>> TypeError: 'DataSetAttributes' object does not support item assignment # get examples (do not work due to previous errors) print(my_polydata_dsa.FieldData["key_1"]) print(my_polydata_dsa.FieldData["key_2"])
I also tried with
.FieldData.append(), but I cannot understand the right syntax.
Thanks very much!