I consider that a VEX language error, but it's so well known that VEX just works that way.
When you enter a primitive or point wrangle, a snapshot of the geometry is presented for your code to work on. Once the wrangle is executed, the snapshot is updated by applying the actions your code generated.
The default sphere contains 266 points. This means the
addpoint() function will always return the next point number of the snapshot total point count of 266. This is why
the documentation [
www.sidefx.com] mentions the return value for
addpoint() is essentially useless. You can use the result to check for an error.
Because you are running in the primitive context, however, you don't need to call the
setprimattrib() function at all, you can assign primitive attributes directly.
// create new point at primitive center
vector center = primuv(0, "P", @primnum, {0.5, 0.5, 0});
int pt = addpoint(0, center);
// reference new point from primitive
//setprimattrib(0, "prim_center", @primnum, pt);
v@prim_center =center;
i@center_point_number = pt; //Check spreadsheet, always the same number.