Expression Functions

Reference chart for Houdini expression functions

Overview

Houdini expression functions are used in parameter fields, channel expressions, and geometry expressions. They provide math, geometry, random, and utility operations for procedural workflows.
Official Houdini Expression Functions Documentation

Expression Functions Chart

NameCodeExampleDescriptionCategory
curvaturecurvature(surface, u, v)curvature(opinputpath(".",0), 0.5, 0.5)Surface curvature at UV.Geometry
degdeg(x)deg($PI) → 180Alias for degrees(x).Math
degreesdegrees(x)degrees($PI) → 180Converts radians to degrees.Math
detaildetail(surface, attrib, index)detail(0, "density", 0)Value of a detail attribute.Geometry
detailsdetails(surface, attrib)details(0, "path")String value of a detail attribute.Geometry
determinantdeterminant(matrix)determinant(identity()) → 1Determinant of matrix.Matrix
dihedraldihedral(v0, v1)dihedral({0,1,0},{0,0,1})Dihedral rotation matrix aligning v0 to v1.Matrix/Math
distancedistance(p1, p2)distance({0,0,0},{1,1,1}) → 1.732Distance between two 3D points.Vector/Math
dopfielddopfield(object, data, subdata, record, field, index)dopfield("..:object","..:data","..","..","vel",0)Value of a DOP field (float).DOP
dopfieldsdopfields(object, data, subdata, record, field, index)dopfields("..","..","..","..","name",0)Value of a DOP field (string).DOP
dopframedopframe()dopframe()Current simulation frame (DOPs).DOP
doptimedoptime()doptime()Current simulation time (DOPs).DOP
doptransformdoptransform(object, data, subdata, record)doptransform("..","..","..","..")Transformation matrix for DOP data.DOP
dotdot(a, b)dot({1,0,0}, {0,1,0}) → 0Dot product of two vectors.Vector/Math
edgegrouplistedgegrouplist(surface)edgegrouplist(0)List of edge groups in SOP.Geometry
edgegroupmaskedgegroupmask(surface, pattern)edgegroupmask(0, "seam*")Edge groups matching pattern.Geometry
expexp(x)exp(1) → 2.718e raised to x.Math
fitfit(x, oldmin, oldmax, newmin, newmax)fit(0.5, 0, 1, 10, 20) → 15Remaps x from one range to another.Math
fit01fit01(x, newmin, newmax)fit01(0.25, 10, 20) → 12.5Maps x∈[0,1] to [newmin, newmax].Math
fit10fit10(x)fit10(0.2) → 0.2Maps x to [0,1] (clamped/normalized).Math
fit11fit11(x)fit11(0.5) → 0.0Maps x to [-1,1].Math
floorfloor(x)floor(2.7) → 2Largest integer ≤ x.Math
fpadzerofpadzero(width, number)fpadzero(5, 3.2) → "03.2"Zero-pad with float handling.String
fracfrac(x)frac(2.7) → 0.7Fractional part of x.Math
ftoaftoa(x)ftoa(3.14) → "3.14"Number to string.String
ftrimftrim(x, digits)ftrim(3.14159, 3) → "3.142"Format float string with rounding.String
groupbyvalgroupbyval(surface, class, attrib, value)groupbyval(0, "point", "id", 3)Set of elements with a given integer attribute value.Geometry
groupbyvalsgroupbyvals(surface, class, attrib, value)groupbyvals(0, "prim", "name", "wall")Set by string attribute value.Geometry
hasdetailattribhasdetailattrib(surface, attrib)hasdetailattrib(0, "class")Returns 1 if detail attribute exists.Geometry
haspointhaspoint(surface, group, ptnum)haspoint(0, "sel", 12)Returns 1 if point is in group.Geometry
haspointattribhaspointattrib(surface, attrib)haspointattrib(0, "Cd")Returns 1 if point attribute exists.Geometry
hasprimhasprim(surface, group, primnum)hasprim(0, "sel", 7)Returns 1 if prim is in group.Geometry
hasprimattribhasprimattrib(surface, attrib)hasprimattrib(0, "name")Returns 1 if prim attribute exists.Geometry
hasvertexattribhasvertexattrib(surface, attrib)hasvertexattrib(0, "uv")Returns 1 if vertex attribute exists.Geometry
hextointhextoint(hex)hextoint("FF") → 255Hex string → integer.String
hsvhsv(r, g, b)hsv(1, 0.5, 0.5)RGB → HSV components.Color
identityidentity()identity() → 4×4 IIdentity matrix.Matrix
indexindex(string, pattern)index("abcabc","ab") → 0First occurrence of pattern in string.String
instancepointinstancepoint()instancepoint()Point number currently being instanced onto.Instancing
intint(x)int(2.9) → 2Truncates x to integer.Math
inttohexinttohex(i)inttohex(255) → "FF"Integer → hex string.String
invertinvert(matrix)invert(identity()) → identity()Inverts a matrix.Matrix
lengthlength(v)length({3,4,0}) → 5Length (magnitude) of vector v.Vector/Math
listbyvallistbyval(surface, class, attrib, value)listbyval(0, "prim", "class", 2)List elements with given integer attribute value.Geometry
listbyvalslistbyvals(surface, class, attrib, value)listbyvals(0, "point", "name", "pt*")List by string attribute value.Geometry
locklock(value)lock(ch("tx"))Value that cannot be changed by further evaluation.Channel
loglog(x)log(1) → 0Natural logarithm of x.Math
log10log10(x)log10(100) → 2Base-10 logarithm of x.Math
loplastmodifiedprimloplastmodifiedprim()loplastmodifiedprim()Path of USD prim last modified by node.LOP/USD
lopparentprimslopparentprims(prims)lopparentprims("/root/*")Parent paths of USD prims.LOP/USD
ltrimltrim(string)ltrim(" hi") → "hi"Trim whitespace at start.String
matchmatch(pattern, string)match("foo*","foobar") → 1Glob-style match test.String
matrixmatrix(spec)matrix("1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1")Create matrix from string.Matrix
matrixtoquatmatrixtoquat(m)matrixtoquat(identity())Rotation matrix → quaternion.Matrix
maxmax(a, b)max(3,5) → 5Larger of a, b.Math
minmin(a, b)min(3,5) → 3Smaller of a, b.Math
mlookatmlookat(from, to)mlookat({0,0,0}, {0,0,-1})Look-at transform matrix (Z forward).Matrix
mlookatupmlookatup(from, to, up)mlookatup({0,0,0},{0,0,-1},{0,1,0})Look-at with explicit up vector.Matrix
mobjlookatmobjlookat(obj_from, obj_to)mobjlookat("../cam1","../null1")Object-to-object look-at matrix.Matrix
nearpointnearpoint(surface, x, y, z)nearpoint(0, 0.1, 0.2, 0.3)Nearest point to world position.Geometry
noisenoise(x, y, z)noise(0.1,0.2,0.3)3D noise value.Noise
normalizenormalize(v)normalize({2,0,0}) → {1,0,0}Normalizes a vector.Vector/Math
npointsnpoints(surface)npoints(0)Number of points in geometry.Geometry
npointsgroupnpointsgroup(surface, groupname)npointsgroup(0, "mygrp")Number of points in group.Geometry
nprimsnprims(surface)nprims(0)Number of primitives in geometry.Geometry
nprimsgroupnprimsgroup(surface, groupname)nprimsgroup(0, "grps")Number of prims in group.Geometry
nverticesnvertices(surface)nvertices(0)Number of vertices in geometry.Geometry
nverticesgroupnverticesgroup(surface, groupname)nverticesgroup(0, "edgegrp")Number of vertices in group.Geometry
oldrandoldrand(seed)oldrand(1)Legacy random (0..1).Random
opdigitsopdigits(path)opdigits("box3") → 3Numeric suffix of a node name.OP/Node
opexistopexist(path)opexist("../geo1") → 1/01 if node/group/bundle exists.OP/Node
opflagopflag(flag, pattern)opflag("display", "/obj/*")List nodes with a flag set.OP/Node
opfullpathopfullpath(path)opfullpath("../geo1") → "/obj/geo1"Absolute path of a node.OP/Node
opnameopname(path)opname("../geo1") → "geo1"Name of a node from its path.OP/Node
opnchildrenopnchildren(path)opnchildren("/obj")Number of nodes inside a container.OP/Node
opninputsopninputs(path)opninputs("../merge1")Max number of connected inputs.OP/Node
opnodigitsopnodigits(path)opnodigits("box3") → "box"Alphanumeric prefix sans trailing digits.OP/Node
opnoutputsopnoutputs(path)opnoutputs("../switch1")Number of connected outputs.OP/Node
oprelativepathoprelativepath(from, to)oprelativepath("../geo1","/obj") → "../.."Relative path between nodes.OP/Node
opselectopselect()opselect() → listSelected nodes (list).OP/Node
optransformoptransform(object_path)optransform("../geo1")Object transform matrix at current time.Object/Xform
optypeoptype(path)optype("../box1") → "box"Type name of a node.OP/Node
optypeinfooptypeinfo(path)optypeinfo("../box1")Type info about a node.OP/Node
originorigin(object_path, space, type)origin("../xform1", "D_WORLDSpace", D_ZROT)Object transform components (origin/rotation/etc.).Object/Xform
originoffsetoriginoffset(object_path, space, type)originoffset("../xform1", "D_WORLDSpace", D_ZROT)Object offset transform components.Object/Xform
padzeropadzero(width, number)padzero(4, 12) → "0012"Zero-pad a number to width.String
pdgattribpdgattrib(name)pdgattrib("workitemindex")Value of a PDG work item attribute.PDG/TOP
pdginputpdginput(index, tag)pdginput(0, "file/geo")Work item input file by index and tag.PDG/TOP
pdgoutputpdgoutput(index, tag)pdgoutput(0, "file/geo")Work item output file by index and tag.PDG/TOP
picpic(cop, x, y, plane)pic("/img/comp1/IN", 100,200, "C")Interpolated pixel color from COP.COP/Image
picnipicni(cop, x, y, plane)picni("/img/comp1/IN", 100,200, "C")Non-interpolated pixel color from COP.COP/Image
pluralizepluralize(noun)pluralize("box") → "boxes"English plural of a noun.String
pointpoint(surface, point_number, attrib, index)point(0, 0, "P", 0)Value of a point attribute.Geometry
pointdistpointdist(surface, ptnum, prim, u, v, w)pointdist(0, 0, 1, 0.5, 0.5, 0)Distance from point to primitive.Geometry
pointgrouplistpointgrouplist(surface)pointgrouplist(0)List of point groups in SOP.Geometry
pointgroupmaskpointgroupmask(surface, pattern)pointgroupmask(0, "left*")Group names matching pattern.Geometry
pointspoints(surface, point_number, attrib)points(0, 0, "name")String value of a point attribute.Geometry
powpow(x, y)pow(2,3) → 8x raised to power y.Math
primprim(surface, prim_number, attrib, index)prim(0, 0, "Cd", 0)Value of a primitive attribute.Geometry
primbboxbbox(surface, D_XMIN)bbox("../geo1", D_YMAX)Per-prim bbox via bbox() types.Geometry
primduvprimduv(surface, primnum, attrib, u, v, w)primduv(0, 0, "P", 0.5, 0.5, 0)Partial derivatives at UV on primitive.Geometry
primgrouplistprimgrouplist(surface)primgrouplist(0)List of primitive groups in SOP.Geometry
primgroupmaskprimgroupmask(surface, pattern)primgroupmask(0, "roof*")Primitive groups matching pattern.Geometry
primsprims(surface, prim_number, attrib)prims(0, 0, "name")String value of a primitive attribute.Geometry
primuvprimuv(surface, primnum, attrib, u, v, w, comp)primuv(0, 0, "P", 0.5, 0.5, 0, 0)Attribute value at UV/UVW on primitive.Geometry
pulsepulse(x, start, end)pulse($F, 10, 20) → 1 on frames 10–201 when x is within range [start, end], else 0.Utility
quattomatrixquattomatrix(q)quattomatrix({0,0,0,1})Quaternion → 3×3 rotation matrix.Matrix
radrad(x)rad(180) → $PIConverts degrees to radians.Math
randrand(seed)rand(123) → 0..1Pseudo-random number 0..1.Random
resres(cop)res("/img/comp1/IN") → 1920 1080Natural resolution of COP image.COP/Image
rgbrgb(h, s, v)rgb(0.0, 1.0, 1.0)HSV → RGB components.Color
rindexrindex(string, pattern)rindex("abcabc","ab") → 3Last occurrence of pattern in string.String
rintrint(x)rint(2.5) → 3Rounds x to nearest integer.Math
rotaterotate(angle, axis)rotate(90, {0,1,0})4×4 rotation matrix from angle+axis.Matrix
rotaxisrotaxis(angle, axis)rotaxis(45, {1,0,0})4×4 rotation from axis-angle.Matrix
roundround(x)round(2.4) → 2Rounds x to nearest integer.Math
rtrimrtrim(string)rtrim("hi ") → "hi"Trim whitespace at end.String
sinsin(x)sin(0) → 0Sine of x (radians).Math
sinhsinh(x)sinh(0) → 0Hyperbolic sine of x.Math
sqrtsqrt(x)sqrt(9) → 3Square root of x.Math
tantan(x)tan(0) → 0Tangent of x (radians).Math