VTK 9.6: How to use GetCellTypes to replace GetCellTypesArray in Python?

I’m trying to upgrade my code to use 9.6 instead of 9.4. I used to use GetCellTypesArray to get the cell type for every cell in my unstructured grid. The deprecation warning says to use GetCellTypes instead. However, this function wants an argument and won’t be called without one. If I try passing in an empty vtkCellTypes variable, it populates it, but I can’t get that to run through vtk_to_numpy.

I’m just looking for a replacement for: cellTypes = vtk_to_numpy(ug.GetCellTypesArray())

The help shows that it should be able to be called without an argument and do what I need, so I’m not sure what I’m missing.

Thanks!

You should be able to call GetCellTypes() with no arguments. Please double-check the version of vtk that you are using.

>>> import vtkmodules
>>> vtkmodules.__version__
'9.6.1'
>>> from vtkmodules.vtkCommonDataModel import vtkUnstructuredGrid
>>> ug = vtkUnstructuredGrid()
>>> ug.GetCellTypes()
<vtkmodules.vtkCommonCore.vtkUnsignedCharArray(0x562161ce43b0) at 0x7fa56b868ca0>

Sorry. This is completely my fault. I was back on 9.4.1 somehow.