VEX : is it possible to rebuild a polygon?

   587   3   1
User Avatar
Member
68 posts
Joined: April 2020
Offline
say you want to add some points to a polygon (without losing the polygon indice). is there any way to do that?

i see there's the setprimvertex() function which lets you reassign a poly's point, but as far as i can tell, it won' let you change the number of points in the polygon, thus it won't work for this.

thanks in advance!
-seneca
User Avatar
Member
502 posts
Joined: July 2005
Offline
There is a removevertex function. You can store all primitive points or vertices in an array. First you can remove all vertices (or a subset) and after this you can use a modified point list to add them (with addvertex function) again.
Edited by Aizatulin - April 8, 2025 13:17:00

Attachments:
rebuild_same_polyA.hipnc (117.2 KB)

User Avatar
Member
1132 posts
Joined: April 2017
Offline
You can create a new polygon from scratch in steps:
1. if you dont already have points, create them with the addpoint function
2. create a new primitive so you can "store" the vertices into with the addprim function
3. finally, use the addvertex function to create the polygon

If you dont already have the points, in a Detail wrangle you could do:

vector pt0pos = set(1,0,0);
vector pt1pos = set(1,1,0);
vector pt2pos = set(0,1,0);
// all positions
int npt0 = addpoint(0, pt0pos);
int npt1 = addpoint(0, pt1pos);
int npt2 = addpoint(0, pt2pos);
// Points created at the positions
int nprim = addprim(0, "poly");  
// prim created. "poly" for polygons, "polyline" for curves

addvertex(0, nprim, npt0);
addvertex(0, nprim, npt1);
addvertex(0, nprim, npt2);
// creating polygons with the prim and points you previously created
Edited by olivierth - April 8, 2025 13:29:50

Attachments:
Houdini_Wrangle_create_polygon_01.JPG (57.0 KB)

User Avatar
Member
68 posts
Joined: April 2020
Offline
Aizatulin
There is a removevertex function. You can store all primitive points or vertices in an array. First you can remove all vertices (or a subset) and after this you can use a modified point list to add them (with addvertex function) again.

that is awesome! that's exactly what i was looking for. thanks so much!
  • Quick Links