Houdini 16.5 VEX

Working with geometry groups in VEX

You can read the contents of primitive/point/vertex groups in VEX as if they were attributes.

On this page

Dedicated functions

VEX has a number of functions for working with geometry groups:

Get the number of elements in a group

Test if a given element number is in a group

Convert a group name or group syntax into a list of point/primitive numbers

Modify the contents of a named group

Adding an element to a non-existant group creates the group.

Reading groups as attributes

The generic attribute reading function attrib takes an attribclass argument that lets you specify what geometry level (detail, primitive, point, or vertex) to read the attribute from.

You can instead specify "primgroup", "pointgroup", or "vertexgroup" as the class to read group contents as if they were attributes.

When you specify these classes, the "element number" is an index into the group list, and the "attribute value" is the point/primitive/vertex number at the given index into the list.

Get the primitive numbers in the foo primitive group

int group_size = attriblen()
int prim_num;
for (int i = 0; i < group_size; i++) {
    // When using a "*group" class, the element number is an index into the group list
    prim_num = attrib(0, "primgroup", "foo", i)
    // ...do something to the primitive...



Next steps