# How to get "connectivity", "offsets", "faces", "faceoffsets" array from "Cell" in unstructured polyhedral grid

**URL:** https://discourse.vtk.org/t/how-to-get-connectivity-offsets-faces-faceoffsets-array-from-cell-in-unstructured-polyhedral-grid/2244
**Category:** Support
**Created:** [December 9, 2019, 6:02pm UTC](https://discourse.vtk.org/t/how-to-get-connectivity-offsets-faces-faceoffsets-array-from-cell-in-unstructured-polyhedral-grid/2244 "2019-12-09T18:02:39Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![pcs](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/p/9d8465/32.png) [@pcs](https://discourse.vtk.org/u/pcs)
#### Post date: [December 9, 2019, 6:02pm UTC](https://discourse.vtk.org/t/how-to-get-connectivity-offsets-faces-faceoffsets-array-from-cell-in-unstructured-polyhedral-grid/2244/1 "2019-12-09T18:02:39Z")

</div>

I have an XML unstructured grid with polyhedral elements and would like to read it using Python for post-processing analysis of a simulation. I can read the file with `vtkXMLUnstructuredGridReader` and successfully read some arrays from `CellData` and `Points` doing the following:

```
import vtk 
import numpy

reader = vtk.vtkXMLUnstructuredGridReader()
reader.SetFileName("cells_0.0000.vtu")
reader.Update()
output = reader.GetOutput()

cellType = output.GetCellData().GetArray("cellType")
cellEnergy = output.GetCellData().GetArray("cellEnergy")
points = output.GetPoints().GetData()

```

I can also read `Cells` without any problems:

```
vtkCells = output.GetCells()
print(vtkCells)

```

Output:

```
vtkCellArray (0x7fcaa7430a10)
  Debug: Off
  Modified Time: 587
  Reference Count: 2
  Registered Events: (none)
  Number Of Cells: 1091
  Insert Location: 0
  Traversal Location: 0

```

However, I haven’t found functions to read the following arrays from `Cell`:

- `connectivity`
- `offsets`
- `faces`
- `facesoffsets`

I have tried some functions from the `vtkCellArray` class ([https://vtk.org/doc/nightly/html/classvtkCellArray.html](https://vtk.org/doc/nightly/html/classvtkCellArray.html)), such as `GetConnectivityArray()` and `GetOffsetsArray()`, but get an error when doing the following:

```
vtkConnectivity = output.GetCells().GetConnectivityArray()

```

Output:

```
AttributeError: 'vtkCommonDataModelPython.vtkCellArray' object has no attribute 'GetConnectivityArray'

```

What function should I use to read `connectivity`, `offsets`, `faces`, and `facesoffsets` arrays?

---

<div class="post-metadata">

### Author: ![allison.vacanti](https://discourse.vtk.org/user_avatar/discourse.vtk.org/allison.vacanti/32/679_2.png) [@allison.vacanti](https://discourse.vtk.org/u/allison.vacanti)
#### Post date: [December 11, 2019, 10:58pm UTC](https://discourse.vtk.org/t/how-to-get-connectivity-offsets-faces-faceoffsets-array-from-cell-in-unstructured-polyhedral-grid/2244/2 "2019-12-11T22:58:45Z")

</div>

As mentioned in the other thread, some of that `vtkCellArray` API was added in a more recent version of VTK.

But if you’re interested in faces, etc, it’d be better to go through the `vtkUnstructuredGrid` API, as it has dedicated methods for dealing with faces – faces aren’t easy to work with at the `vtkCellArray` layer.

---

<div class="post-metadata">

### Author: ![banesullivan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/banesullivan/32/7143_2.png) [@banesullivan](https://discourse.vtk.org/u/banesullivan)
#### Post date: [December 12, 2019, 5:27am UTC](https://discourse.vtk.org/t/how-to-get-connectivity-offsets-faces-faceoffsets-array-from-cell-in-unstructured-polyhedral-grid/2244/3 "2019-12-12T05:27:50Z")

</div>

For the records/archive: this was addressed in [https://github.com/pyvista/pyvista-support/issues/82](https://github.com/pyvista/pyvista-support/issues/82)
