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

**URL:** https://discourse.vtk.org/t/can-i-return-cell-types-from-a-vtkpolydata-using-the-python-bindings/9159
**Category:** Support
**Created:** [August 16, 2022, 7:25pm UTC](https://discourse.vtk.org/t/can-i-return-cell-types-from-a-vtkpolydata-using-the-python-bindings/9159 "2022-08-16T19:25:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![scotsman60](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scotsman60/32/6000_2.png) [@scotsman60](https://discourse.vtk.org/u/scotsman60)
#### Post date: [August 16, 2022, 7:25pm UTC](https://discourse.vtk.org/t/can-i-return-cell-types-from-a-vtkpolydata-using-the-python-bindings/9159/1 "2022-08-16T19:25:48Z")

</div>

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.

```auto
virtual void vtkDataSet::GetCellTypes	(	vtkCellTypes * types	)	

```

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

```auto
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

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [August 16, 2022, 10:50pm UTC](https://discourse.vtk.org/t/can-i-return-cell-types-from-a-vtkpolydata-using-the-python-bindings/9159/2 "2022-08-16T22:50:46Z")

</div>

No “reference” required here. See [vtkCellTypes](https://vtk.org/doc/nightly/html/classvtkCellTypes.html).

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

```

---

<div class="post-metadata">

### Author: ![scotsman60](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scotsman60/32/6000_2.png) [@scotsman60](https://discourse.vtk.org/u/scotsman60)
#### Post date: [August 16, 2022, 11:59pm UTC](https://discourse.vtk.org/t/can-i-return-cell-types-from-a-vtkpolydata-using-the-python-bindings/9159/3 "2022-08-16T23:59:21Z")

</div>

Thanks David - I realized I misread the argument type ☹

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

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