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

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()
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()


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 (, such as GetConnectivityArray() and GetOffsetsArray(), but get an error when doing the following:

vtkConnectivity = output.GetCells().GetConnectivityArray()


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

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

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.

For the records/archive: this was addressed in