Connecting points by corresponding IDs

calendar_today

11.09.2022

label

Modeling, VEX

mouse

Houdini 18.5

Description

Three ways to connect points by common IDs. Use the enumerate SOP to give each point an individual ID before creating duplicates.

1 SOPs

Add SOP: Polygons > By group > By attribute: id

2 H-Script + VEX

Grid set to rows:

C
        // HScript expressions for grid resolution
nuniquevals('../copy1', D_POINT, 'id')
nuniquevals('../copy1', D_PRIMITIVE, 'copynum')
    
C
        // point wrangle for connecting
int index = vertexprimindex(0, i@vtxnum);
int pt_crv = findattribval(1, 'point', 'id', i@primnum, index);
v@P = point(1, 'P', pt_crv);
    

3 VEX

C
        // detail wrangle
int num = nuniqueval(0, 'point', 'id');
for(int i = 0; i < num; i++){
    int pts[] = {};
    int count = findattribvalcount(0, 'point', 'id', i);
    for(int k = 0; k < count; k++){
        int pt = findattribval(0, 'point', 'id', i, k);
        append(pts, pt);
    }
    int prim_crv = addprim(0, 'polyline', pts);
    setprimgroup(0, 'connect', prim_crv, 1, 'set');
}
    

nuniqueval() returns how many IDs exist in total.
findattribvalcount() returns the number of points that share the same ID.
findattribval() returns the point number of each member with the same ID.

download

Downloads

link

Related articles

favorite

137

label

Modeling

Adaptive Resampling of Curves

favorite

281

label

Modeling

Applying Scales to Mesh Surfaces

favorite

224

label

Modeling

Approximating subdivision surfaces

favorite

187

label

Modeling

Blending COPs SDFs into 3D Volume

favorite

271

label

Modeling

Branching Subdivision Curves

favorite

129

label

Modeling

Circuit Networks