Below you will find pages that utilize the taxonomy term “Houdini”
Python wrapper for hscript
Houdini has a nice little function in Python in the hou
namespace called hscript
.
You can pass in a string for an hscript command.
It passes back out a tuple with stdout and stderr strings.
This is dandy,
but it would be nice to call hscript commands with (in essence) Python syntax.
So I made a little class that does just that.
class HscriptWrapper(object):
commands = hou.hscript('help')[0]
commands = frozenset(commands.split())
def __getattr__(self, attr):
if attr not in self.commands:
raise AttributeError('No hscript command by name "%s"' % attr)
# cache for future calls
self.__dict__[attr] = rattr = self._command_factory(attr)
return rattr
def _command_factory(self, attr):
def cmd(*args, **kwargs):
fmt = '{cmd} {flags} {args}'
hsargs = ' '.join(args)
hsflags = []
for k, v in kwargs.items():
if isinstance(v, bool) and v is True:
hsflags.append('-' + k)
else:
hsflags.append('-{0} {1}'.format(k, v))
hsflags = ' '.join(hsflags)
hscmd = fmt.format(cmd=attr, flags=hsflags, args=hsargs)
return hou.hscript(hscmd)
cmd.__name__ = attr
cmd.__doc__ = hou.hscript('help {}'.format(attr))[0]
return cmd
To use it, create an instance of the HscriptWrapper class, then access hscript commands as attributes of the instance. The returned attribute is a callable function that takes positional and keyword arguments.
Houdini Rigging
I am generally pretty sad with the number of free tutorials about Houdini rigging. Thus, I have started a series of them on youtube. They aren’t polished or even really planned out before hand. Really, they are little more than just stream of consciousness, but they have information, which is the important part. If you are interested in certain topics relating to Houdini rigging, post a comment and let me know what you want me to cover next.