# How to get IDs of points attached to the cell?

**URL:** https://discourse.paraview.org/t/how-to-get-ids-of-points-attached-to-the-cell/4314
**Category:** ParaView Support
**Tags:** python
**Created:** [May 12, 2020, 11:36am UTC](https://discourse.paraview.org/t/how-to-get-ids-of-points-attached-to-the-cell/4314 "2020-05-12T11:36:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Andrei](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/9fc29f/32.png) [@Andrei](https://discourse.paraview.org/u/Andrei)
#### Post date: [May 12, 2020, 11:36am UTC](https://discourse.paraview.org/t/how-to-get-ids-of-points-attached-to-the-cell/4314/1 "2020-05-12T11:36:59Z")

</div>

Please help how to get IDs of points attached to the given cell (in order to to find coordinates of the points forming the given cell)? I have cell and point data after the next script:

paraViewData=FindSource(my\_project.pvd’)  
pythonData=servermanager.Fetch(paraViewData)  
cellData=pythonData.GetCellData()  
pointData=pythonData.GetPointData()

Generally, I need to determine the geometric center of the cells in python. I see that the Cell Centers Filter is not fully consistent with the task of determining the exact geometric center. So I am going to determine the center of gravity of the cell explicitly through the coordinates of its vertices using Python script

---

<div class="post-metadata">

### Author: ![ymjia](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/y/ccd318/32.png) [@ymjia](https://discourse.paraview.org/u/ymjia)
#### Post date: [May 12, 2020, 3:44pm UTC](https://discourse.paraview.org/t/how-to-get-ids-of-points-attached-to-the-cell/4314/2 "2020-05-12T15:44:32Z")

</div>

There may be several ways, you can try this:  
from vtk import \*  
cellIds = vtkIdList() # cell ids store to  
pythonData.GetCellPoints(0, cellIds) # get cell ids  
for i in range(0, cellIds.GetNumberOfIds()):  
pythonData.GetPoint(cellIds.GetId(i)) # get coordinate, type : class tuple

btw You can use dir(pythonData) to get documents or check c++ code in paraview source to findout which function to use

---

<div class="post-metadata">

### Author: ![Andrei](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/9fc29f/32.png) [@Andrei](https://discourse.paraview.org/u/Andrei)
#### Post date: [May 13, 2020, 8:25pm UTC](https://discourse.paraview.org/t/how-to-get-ids-of-points-attached-to-the-cell/4314/3 "2020-05-13T20:25:11Z")

</div>

Many thanks for the help!  
I completed the above example according to your advice

```
paraViewData=FindSource('my_project.pvd')
SetActiveSource(paraViewData)
UpdatePipeline()
pythonData=servermanager.Fetch(paraViewData)
numberOfCells=pythonData.GetNumberOfCells()
from vtk import *
cellIds = vtkIdList() # cell ids store to
for cellIndex in range(numberOfCells): # for every cell
   pythonData.GetCellPoints(cellIndex, cellIds) # get ids of points of the given cell
   for i in range(0, cellIds.GetNumberOfIds()): # for every points of the given cell
      coord=pythonData.GetPoint(cellIds.GetId(i)) # get coordinates of the given point of the given cell, type: class 'tuple'
      x=coord[0] # get coordinates of the given point of the given cell, type: class 'float'
      y=coord[1]
      z=coord[2]

```

Regarding the definition of geometric centers of cells the `Cell Centers` filter reliability can be improved by adding the `Clean to Grid` filter before `Cell Centers` as explained here [ParaView Cell Centers possible unstable program behavior](https://discourse.paraview.org/t/paraview-cell-centers-possible-unstable-program-behavior/4310/4)
