Connecting points by corresponding IDs

calendar_today

11.09.2022

label

Modeling

mouse

Houdini 18.5

1 Introduction

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

2 SOPs

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

3 H-Script + VEX

Grid set to rows:

// HScript expressions for grid resolution
nuniquevals('../copy1', D_POINT, 'id')
nuniquevals('../copy1', D_PRIMITIVE, 'copynum')
// 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);

4 VEX

// 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