Posts
Houdini - Startup Settings
The path to the user’s directory is stored in the environment variable HOUDINI_USER_PREF_DIR.
windows: ${HOME}\Documents\houdini18.0
Startup Scripts Startup scripts are located in ${$HOUDINI_USER_PREF_DIR}/scripts.
When Houdini starts up, it sources for 123.py. This is executed only once when Houdini launches.
To execute a script on each scene load, Houdini sources for 456.py in the same scripts folder. This file is also executed when Houdini first launches the default untitled.hip.
Posts
Houdini VEX - Attributes Inside VOPs
Inside a VOP node, an attribute is dubiously called a bound variable. We read/write attributes inside a VOP with the bind operator.
bind1 reads an attribute from outside the VOP called one.
bind2 creates an attribute and exports it outside.
The end result of this DAG is a red object!
Posts
Houdini VEX - Looping
A few variables are available for referencing in a Wrangle:
@ptnum – current point number up to @numpt @elemnum – current index of this element up to @numelem Their equivalents are @primnum, @numprim etc.
To loop over every point:
vector positions[] = {}; for (int i = 0; i < @numpt; i++) { vector p = point(geoself(), "P", i); push( positions, p); } Using foreach:
foreach(vector position; positions) { // Do something; }
Posts
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:
Posts
Houdini VEX Groups
When you group stuff together with a Group SOP, Houdini simply creates an attribute called @group_{name} whose value is 1 or 0.
So to manually add an element to a group, just create the attribute on the element:
i@group_fuckheads = 1; // Remember to declare i! When acting on a point or prim from a detail:
setpointgroup(0, "selected", ptnum, 1); To check whether an element is in a group, just check for the attribute:
Posts
Houdini VEX Types
Type Syntax float f@name int i@name string s@name vector v@name vector2 u@name vector4 p@name matrix2 2@name matrix3 3@name matrix (4x4) 4@name integer array i[]@name vector array v[]@name string array s[]@name Declaring just a plain vector:
vector scale = {1,2,3}; A vector array: