# automatically adding vertex cells

**URL:** https://discourse.vtk.org/t/automatically-adding-vertex-cells/6534
**Category:** Support
**Created:** [September 2, 2021, 5:44pm UTC](https://discourse.vtk.org/t/automatically-adding-vertex-cells/6534 "2021-09-02T17:44:26Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![bistek](https://discourse.vtk.org/user_avatar/discourse.vtk.org/bistek/32/2344_2.png) [@bistek](https://discourse.vtk.org/u/bistek)
#### Post date: [September 2, 2021, 8:56pm UTC](https://discourse.vtk.org/t/automatically-adding-vertex-cells/6534/4 "2021-09-02T20:56:31Z")

</div>

I was referring to issue [#750](https://discourse.vtk.org/t/error-with-inserting-vertex-cells/750) where it suggests to use this C++ code:

```auto
auto vertexes = vtkSmartPointer<vtkCellArray>::New();
for (int i = 0; i < data->GetNumberOfPoints(); i++) {
    vtkIdType pid[1];
    pid[0] = i;
    vertexes->InsertNextCell(1, pid);
}
dataPoints->SetPoints(points);
dataPoints->SetVerts(vertexes);

```

However it is not clear to me how to translate in Python the “pid” lines.

I also found this on an [older post](https://marc.info/?l=vtkusers&m=126322064225373&w=2), but it rises many errors.

```
num = model.GetNumberOfPoints()
ids = vtk.vtkIdList()
ids.SetNumberOfIds(num);
model.Allocate(1,1)

for i in range(0, num):
    ids.SetId(i, i)
    model.InsertNextCell(vtk.VTK_VERTEX, ids)

```

In the end, I understand that the error is with the “pid” index, that must be a `vtkIdType`, but I cannot get it correct in Python.

Thanks!

---

_[View the full topic](https://discourse.vtk.org/t/automatically-adding-vertex-cells/6534)._
