Script: Bake Camera

January 5, 2024

import hou selectedNode = hou.selectedNodes()[0] bakingNode = hou.node(‘/obj’).createNode(‘cam’, + ‘_bake’) hou.setFrame(int(hou.playbar.playbackRange()[0])) for f in range(int(hou.playbar.playbackRange()[0]), int(hou.playbar.playbackRange()[1])+1): hou.setFrame(f) bakingNode.setWorldTransform(selectedNode.worldTransform()) bakingNode.parm(“tx”).setKeyframe(hou.Keyframe(bakingNode.parm(“tx”).eval())) bakingNode.parm(“ty”).setKeyframe(hou.Keyframe(bakingNode.parm(“ty”).eval())) bakingNode.parm(“tz”).setKeyframe(hou.Keyframe(bakingNode.parm(“tz”).eval())) bakingNode.parm(“rx”).setKeyframe(hou.Keyframe(bakingNode.parm(“rx”).eval())) bakingNode.parm(“ry”).setKeyframe(hou.Keyframe(bakingNode.parm(“ry”).eval())) bakingNode.parm(“rz”).setKeyframe(hou.Keyframe(bakingNode.parm(“rz”).eval())) bakingNode.parm(‘focal’).setKeyframe(hou.Keyframe(selectedNode.parm(‘focal’).eval())) bakingNode.parm(‘aperture’).setKeyframe(hou.Keyframe(selectedNode.parm(‘aperture’).eval())) bakingNode.parm(‘near’).setKeyframe(hou.Keyframe(selectedNode.parm(‘near’).eval())) bakingNode.parm(‘far’).setKeyframe(hou.Keyframe(selectedNode.parm(‘far’).eval())) bakingNode.parm(‘resx’).setKeyframe(hou.Keyframe(selectedNode.parm(‘resx’).eval())) bakingNode.parm(‘resy’).setKeyframe(hou.Keyframe(selectedNode.parm(‘resy’).eval())) bakingNode.parm(‘winsizex’).setKeyframe(hou.Keyframe(selectedNode.parm(‘winsizex’).eval())) bakingNode.parm(‘winsizey’).setKeyframe(hou.Keyframe(selectedNode.parm(‘winsizey’).eval())) bakingNode.parm(‘shutter’).setKeyframe(hou.Keyframe(selectedNode.parm(‘shutter’).eval())) bakingNode.parm(‘aspect’).setKeyframe(hou.Keyframe(selectedNode.parm(‘aspect’).eval()))

VEX: Point Pitch, Yaw, Roll

June 17, 2020

matrix3 m = maketransform(@N,@up);@orient = quaternion(m); vector4 pitch = quaternion({1,0,0}ch(‘pitch’)); vector4 yaw = quaternion({0,1,0}ch(‘yaw’));vector4 roll = quaternion({0,0,1}*ch(‘roll’)); @orient = qmultiply(@orient, pitch);@orient = qmultiply(@orient, yaw);@orient = qmultiply(@orient, roll);

Python: Phyllotaxis

May 14, 2020

node = hou.pwd() geo = node.geometry() # Add code to modify contents of geo. # Use drop down menu to select examples. from math import radians, sqrt, sin, cos numpoints = 200 angle = 137.508 cval = 0.2 for i in range(numpoints): theta = radians (i * angle) x = cval * sqrt(i) * cos(theta) … Read More

VEX: Create Points at Prim Centres

January 8, 2020

int Pt_Num; @N = @N; Pt_Num = addpoint(0, @P); setpointattrib(geoself(), "N", Pt_Num, @N, "set"); removeprim(0, @primnum, 1);

Python: Split Into Groups

March 13, 2019

This little script for Houdini is one I’ve had knocking about and thought might be useful to throw out onto t’interweb. Select the node at which you want to split out the groups and it will create a bunch of blasts and OUT nodes to separate out per group. import hou selectedNodes = hou.selectedNodes() for … Read More

VEX: split string and convert to integer

September 20, 2018

//Split @anotherAttribute based on ‘_’ string myString[] = split(s@anotherAttribute, “_”); //Use last element as attribute value s@tempString = myString[-1]; //convert string to integer i@myIntegerFromString = atoi(s@tempString);

VEX: Bend Wrangle

September 14, 2018

Taken from //Input is a line //Resample SOP on line for more points //Activate curveu attrib in resample SOP //Remap curveu to shape of bend @curveu=chramp(“ramp”,@curveu); float bamt = chf(“bend_amt”); //bend amount vector benddir = chv(“bend_dir”); //bend direction @P+= benddir * bamt * @curveu;

Houdini Python: Find/Replace Parameter Expression

January 18, 2018

A little script to find/replace strings in selected nodes’, parameter expressions: import hou sel = hou.selectedNodes() dialog = hou.ui.readMultiInput('Find/Replace In Expression', input_labels=['Find: ', 'Replace: ',], buttons=("Find/Replace", "Cancel"), severity=hou.severityType.ImportantMessage, title='Find/Replace', close_choice=1) find = dialog[1][0] replace = dialog[1][1] if dialog[0] == 0: for n in sel: for parms in n.parms(): try: newString = str(parms.eval()).replace(find, replace) parms.set(newString) except: … Read More

VEX: SOP Rotation

May 24, 2017

f@speed = fit01(rand(@ptnum), ch('minSpeed'), ch('maxSpeed')); float angle = (ch('angle')+@ptnum)*@speed; vector axis = sample_direction_uniform(rand(@ptnum*ch('seed'))); @orient = quaternion(angle, axis);

Houdini Tip: Toggle Update Mode

December 17, 2016

I often find that Houdini wants to cook at inconvenient times. To stop this you can enter Manual Mode which is located in the bottom right of the UI. To make toggling between Manual and Auto mode easier and quick it can be scripted and dedicated a hotkey. Googling brought up this feed which … Read More