Hi there,
Lets say I have a straight line with points 1, 2, 3, 4
I want to add a point between 2 and 3
If I simply use addpoint(0, newPosition) I'll get 1, 2, 5, 3, 4
Is there a way of adding a point inbetween 2 and 3 so that the IDs after point 2 increase?
I imagine splitting the array of all points in 2, adding my new array of points and then connecting all 3 together again.
How would I go about that? I think I'm just missing the name of the array that contains all points in my geo, any clues?
Thanks so much in advance!
VEX: Adding pts inbetween pts (and shifting point IDs)
1164 2 1- Florian Thamer
- Member
- 1 posts
- Joined: June 2015
- Offline
- N-G
- Member
- 209 posts
- Joined: March 2018
- Offline
- tamte
- Member
- 8514 posts
- Joined: July 2007
- Online
Florian Thameryou can use primpoints() to get that array for any prim
I think I'm just missing the name of the array that contains all points in my geo, any clues?
so in case you are ultimately after inserting a new point into the existing line
here is a simple case in Primitive Wrangle, just be aware that because the old prim is destroyed and replaced with a new one, the prim attributes will not persist so you may need to manage them separately, as well as intrinsics like 'closed':
int pts[] = primpoints(0, @primnum); //get all points of current prim vector newP = {1,1,1}; //figure out new point's position int newpt = addpoint(0, newP); // create new point int index = 2; insert(pts, index, newpt); // insert new point to desired location removeprim(0, @primnum, 0); // delete incoming prim addprim(0, "polyline", pts); // and create new one from new array of points
the new point will still be highest ptnum
but you can use Sort Sop in By Vertex Order to fix that
Edited by tamte - Feb. 12, 2021 12:12:27
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
-
- Quick Links