Vex Cheat Sheet

Vex type prefixes
floats and integers
f@myfloat = 12.234; // float, i@myint = 5; // integer
Vectors
u@myvector2 = {0.6, 0.5}; // vector2 (2 floats)
v@myvector = {1,2,3}; // vector (3 floats)
p@myquat = {0,0,0,1}; // quaternion / vector4 / 4 floats
Matricies
2@mymatrix2 = {1,2,3,4}; // matrix2 (2×2 floats)
3@mymatrix3 = {1,2,3,4,5,6,7,8,9}; // matrix3 (3×3 floats)
4@mymatrix4 = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; // matrix (4×4 floats)
Strings and Dictionaries
s@mystring = ‘a string’; // string
d@mydict = {}; // dict, can only instantiate as empty type
d@mydict[‘key’] = ‘value’; // can set values once instantiated
i@Frame; // current frame
f@Time; // current time in seconds
i@ptnum; // current point number
i@vtxnum; // current vertex number
i@primnum; // current prim number
i@elemnum; // handy morphing attribute; if you’re in a point wrangle its ptnum, if in a vertex wrangle its @vtxnum, primwrangle @primnum.
i@numpt; // total number of points. both @ptnum and @numpt are integers, so if dividing, remember to cast @ptnum to a float
i@numvtx; // total number of verticies
i@numprim; // total number of prims
v@N; // the normal. If this hasn’t been set, vex will calculate it for you just by calling it without initialised values
v@up; // a vector to control the spin around the normal when using instancing/copytopoints/etc
p@orient; // vector4 used as explicit rotation for instances
3@transform; // matrix3 used to control rotation and scale for instances
4@localtransform; // matrix (4×4) used for kinefx joints
f@pscale; // uniform scale for instances
v@scale; // XYZ scale control for instances
v@P; // current elements position. can be set for points, can be read for vertices and prims.
v@Cd; // diffuse colour
v@v; // velocity, used for rendering and simulation
v@w; // spin velocity used for rbd generally
v@force;
https://www.sidefx.com/docs/houdini/copy/instanceattrs
#define XFORM_SRT 0 // Scale, Rotate, Translate
#define XFORM_STR 1 // Scale, Translate, Rotate
#define XFORM_RST 2 // Rotate, Scale, Translate
#define XFORM_RTS 3 // Rotate, Translate, Scale
#define XFORM_TSR 4 // Translate, Scale, Rotate
#define XFORM_TRS 5 // Translate, Rotate, Scale
#define XFORM_XYZ 0 // Rotate order X, Y, Z
#define XFORM_XZY 1 // Rotate order X, Z, Y
#define XFORM_YXZ 2 // Rotate order Y, X, Z
#define XFORM_YZX 3 // Rotate order Y, Z, X
#define XFORM_ZXY 4 // Rotate order Z, X, Y
#define XFORM_ZYX 5 // Rotate order Z, Y, X
@P => points
@N => normals
@v => velocities
@w => angularVelocities
@accel => accelerations
@id => ids
@uv => primvars:st
@Cd => primvars:displayColor
@Alpha => primvars:displayOpacity
@width,@widths,@pscale => widths
The SIDEFX documentation is here: https://www.sidefx.com/docs/houdini/vex/snippets.html#attributes