Can I return cell types from a vtkPolyData using the Python bindings

Hello!!!

I’m trying to read the cell types in a vtkPolyData using the vtk Python bindings. The method returns the cell types by reference.

virtual void vtkDataSet::GetCellTypes	(	vtkCellTypes * 	types	)	

I’m trying to use the reference class for this as shon elow

from vtkmodules.vtkCommonCore import reference
cell_types = reference(('0'),)
my_poly.GetCellTypes(cell_types)

where ‘my_poly’ is a vtkPolyData, but this throws an exception - ‘TypeError: GetCellTypes argument 1: method requires a VTK object’

Any ideas on how I can get the cell types from the vtkPolyData will be greatly appreciated

No “reference” required here. See vtkCellTypes.

cell_types = vtkCellTypes()
my_poly.GetCellTypes(cell_types)
print("NumberOfCellTypes", cell_types.GetNumberOfTypes())

Thanks David - I realized I misread the argument type :frowning:

And I can get the type data directly into numpy:-

cell_types_np = np.array(cell_types.GetCellTypesArray())