Houdini VEX Attributes
Reading Attributes
To access a point’s attributes:
@Cd = point(0, "Cd", @ptnum) // 0 is the input, or use 'geoself()'
You can access point
, prim
, vertex
, etc. See here.
Remember that inputs are zero-indexed.
To explicitly cast anything in VEX, use set.
float aFloat = 1.0;
int cols = set(aFloat); // cast 'float' to 'int'
int cols = (int)aFloat; // another way
Setting Attributes
To set an attribute:
i@order = 1;
@distance = 2.123; // float, implicit cast
If we are not acting on geoself()
and changing attributes on another object from e.g. from second input, we can use setpointattrib.
vector color = {1, 0, 0};
setpointattrib(1, "Cd", @ptnum, color); // where '1' is the second input
Get all point attributes
To get all point attributes, set a Wrangle SOP to run over
a detail
:
string attribs[] = detailintrinsic(geoself(), "pointattributes");
Read a channel / parameter with VEX
To get a channel/parameter from any node:
float scale = chf("../box1/scale") // like using 'ch' appended with a type
To access other types, you have chi
(int) chs
(string) cfv
(vector) etc.