Difference between revisions of "Houdini Python Cookbook"
From kunz
Views
Actions
Namespaces
Variants
Tools
(Created page with "<syntaxhighlight lang='Python'> for node in hou.node("/").allSubChildren(): node.cook(force=True) </syntaxhighlight>") |
|||
(9 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[https://github.com/kiryha/Houdini/wiki/python-for-artists Python for Artists] | |||
Force the entire scene to cook (all nodes) | |||
<syntaxhighlight lang='Python'> | <syntaxhighlight lang='Python'> | ||
for node in hou.node("/").allSubChildren(): | for node in hou.node("/").allSubChildren(): | ||
node.cook(force=True) | node.cook(force=True) | ||
</syntaxhighlight> | |||
Print the full path of the current Houdini scene | |||
<syntaxhighlight lang='Python'> | |||
print(hou.hipFile.path()) | |||
</syntaxhighlight> | |||
Get the version numbers in the filename | |||
<syntaxhighlight lang='Python'> | |||
hou.hscript('echo -n `opdigits($HIPNAME)`') | |||
</syntaxhighlight> | |||
What platform is Houdini running on? | |||
<syntaxhighlight lang='Python'> | |||
hou.applicationPlatformInfo() | |||
</syntaxhighlight> | |||
List all the [https://jurajtomori.wordpress.com/2018/01/15/houdini-tip-taking-advantage-of-environment-variables/ environment variables] | |||
<syntaxhighlight lang='Python'> | |||
import os | |||
for e in os.environ: | |||
print(e, os.environ[e]) | |||
</syntaxhighlight> | |||
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. | |||
<syntaxhighlight lang='Python'> | |||
hou.text.incrementNumberedString( hou.getenv('HIPNAME') ) | |||
</syntaxhighlight> | |||
Reload a module, useful if you make some changes to the module. | |||
<syntaxhighlight lang='Python'> | |||
import importlib | |||
importlib.reload(module) | |||
</syntaxhighlight> | </syntaxhighlight> |
Latest revision as of 13:12, 16 August 2022
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)