This is a bunch of my python snippets for Houdini. Beware that this is still being created so it’s messy and some of the scripts probably won’t work because they are taken out of content.
![](https://usercontent.one/wp/www.redbjarne.com/wp-content/uploads/2021/12/HouPy1.png)
![](https://usercontent.one/wp/www.redbjarne.com/wp-content/uploads/2021/12/HouPy2.png)
# # # #Change the clipping planes in the viewport. Useful if you often change between extremely large objects and very small ones. import toolutils nearFar = (0.1, 2000000) viewport = hou.ui.paneTabOfType(hou.paneTabType.SceneViewer).curViewport() viewport.defaultCamera().setClipPlanes(nearFar)
# # # #Set Display Flag on a node (the blue button) hou.node('/obj/RoadA_SectionB').setDisplayFlag(True)
# # # #Traverses a network of linked nodes top-down def getBoneNamesFromRoot(in_srcRoot): #input root and traverse linked structure and extract all bone names bones = [] bones = traverseOutputs(in_srcRoot, 0, bones) return bones def traverseOutputs(in_node, in_level, in_rtn): outputs = in_node.outputs() if len(outputs) > 0: in_level += 1 for child in outputs: #only check bone objects if "bone" in child.type().name(): #and skip 'root' bones. The root is the pelvis. if "root" not in child.name(): in_rtn.append(child.name()) print(child.name()) traverseOutputs(child, in_level, in_rtn) return in_rtn
# # # #Create Parameter def setIterations(kwargs): node = kwargs['node'] idx = hou.parm(node.path()+'/noiseType').eval() iterations = hou.parm(node.path()+'/Parms/numTypeVariations').eval()[str(idx)] iteParm = hou.parm(node.path()+'/iterations') iteParm.set(iterations) #create items and labels for the drop down menu labels = ["Perlin", "Original Perlin", "Sparse Convolution", "Alligator", "Simplex", "Analytic Perlin", "Analytic Simplex"] items = [] itm = 0 for l in labels: #create array of numbers items.append(str(itm)) itm += 1 #create/update variations parameter varParm = hou.parm(node.path()+'/noiseVaiations') varParmTmp = None if varParm == None: varParmTmp = hou.IntParmTemplate('noiseVaiations', 'Variations', 1) varParmTmp.setMenuType(hou.menuType.Normal) varParmTmp.setScriptCallback('hou.phm().printSelection(kwargs)') varParmTmp.setScriptCallbackLanguage(hou.scriptLanguage.Python) else: varParmTmp = varParm.parmTemplate() varParmTmp.setMenuItems(items) varParmTmp.setMenuLabels(labels) parmGrp = node.parmTemplateGroup() if parmGrp.find('noiseVaiations') == None: parmGrp.insertAfter('noiseType', varParmTmp) else: parmGrp.replace('noiseVaiations', varParmTmp) node.setParmTemplateGroup(parmGrp)