Houdini 17.0 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.

Getting the existing groups

You can get an array of existing group names by reading the "intrinsic" detail attributes edgegroups, pointgroups, primitivegroups, or vertexgroups.

string groups[] = detailintrinsic(0, "pointgroups")

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...
}

VEX

Language

Next steps

Reference