It is often useful to select cells by their type for visualization in ParaView. Visualizing boundary layer meshes for example or extracting the surface elements of a mesh can be done by using the following script in the Programmable filter of ParaView.

input = self.GetUnstructuredGridInput()
output = self.GetUnstructuredGridOutput();

# copy all curent data
output.GetPointData().PassData(input.GetPointData())
output.GetCellData().PassData(input.GetCellData())

# create an array holding the VTK cell type id of each element
cellTypes = vtk.vtkUnsignedCharArray()
cellTypes.DeepCopy(input.GetCellTypesArray())
cellTypes.SetName("Cell Types")
output.GetCellData().AddArray(cellTypes)

Even simpler you can import this file (export_cell_types.cpd ) from the menu Tools>Manage Custom Filters… > Import.

source