Houdini Python Cookbook: Difference between revisions
From kunz
More actions
No edit summary |
No edit summary |
||
| Line 52: | Line 52: | ||
node = hou.pwd() | node = hou.pwd() | ||
geo = node.geometry() | geo = node.geometry() | ||
geo.addAttrib(hou.attribType.Point, | geo.addAttrib(hou.attribType.Point, 'file', '') | ||
dir ='/ | dir ='C:/Users/john/Desktop/New folder/geo/' | ||
for | for filename in os.listdir(dir) : | ||
if | if filename.endswith('.bgeo.sc') : | ||
pt = geo.createPoint() | pt = geo.createPoint() | ||
pt.setAttribValue('file', dir+ | pt.setAttribValue('file', dir+filename) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 21:37, 24 September 2026
Force the entire scene to cook (all nodes)
for node in hou.node("/").allSubChildren():
node.cook(force=True)
Print the full path of the current Houdini scene
print(hou.hipFile.path())
Get the version numbers in the filename
hou.hscript('echo -n `opdigits($HIPNAME)`')
What platform is Houdini running on?
hou.applicationPlatformInfo()
List all the environment variables
import os
for e in os.environ:
print(e, os.environ[e])
Increment number at the end of a text string. This is the algorithm used by Houdini to generate uniquely named child nodes inside a network.
hou.text.incrementNumberedString( hou.getenv('HIPNAME') )
Reload a module, useful if you make some changes to the module.
import importlib
importlib.reload(module)
Get the transform of a specific prim
hou.node('/obj/asset_stitching/blast28').geometry().prims()[0].intrinsicValue('transform')
Python SOP, create a point for every bgeo.sc file in a directory
import os
node = hou.pwd()
geo = node.geometry()
geo.addAttrib(hou.attribType.Point, 'file', '')
dir ='C:/Users/john/Desktop/New folder/geo/'
for filename in os.listdir(dir) :
if filename.endswith('.bgeo.sc') :
pt = geo.createPoint()
pt.setAttribValue('file', dir+filename)