Points & geometry

setpointattrib Example (VEX)

Create a point with addpoint, then write an attribute onto that specific point with setpointattrib - the idiom for building geometry in a wrangle.

What it does

Creates a new point and writes an attribute value onto it by point number. Where @Cd = ... edits the current element, setpointattrib lets you write to any point you name - including one you just added.

When to use it

Use it whenever you generate geometry in a wrangle and need to set attributes on the new elements: scattering points, building curves, or emitting from a detail wrangle where there is no current point to bind.

The VEX code

int pt = addpoint(0, set(0, 0, 0));
// addpoint returns the new point number; pass it to setpointattrib.
// The final arg is the write mode ("set", "add", "max", and so on).
setpointattrib(0, "Cd", pt, {1, 0, 0}, "set");
Context: paste this into an Attribute Wrangle running over points, unless noted otherwise.

Inputs and assumptions

Common mistakes

Frequently asked questions

What is the difference between @Cd and setpointattrib?

@Cd writes to the current element the wrangle is running on; setpointattrib writes to any point by number, including points you create with addpoint.

Which wrangle should I use setpointattrib in?

Any, but it is most common in a detail or points wrangle when you are generating geometry and setting attributes on new points.

Open Houdini VEX Lab