[Sidefx-houdini-list] Take and Python ?

Lars van der Bijl com48com at gmail.com
Mon Nov 19 12:29:40 EST 2012

there was a nice active take module in the Cortex-vfx a while back..
can't find the script right now in the trunk but it goes something like

import hou

class ActiveTake:
        A context object intended for use with python's "with" syntax. It
        that all operations in the with block are performed in the given
        and that the previous take is restored if it still exists when the
block exits.

    def __init__(self, take):
        self.__take = take
        self.__prevTake = ActiveTake.name()

    def __enter__(self):
        if self.__take in ActiveTake.ls():
            hou.hscript("takeset %s" % self.__take)

    def __exit__(self, exitType, value, traceBack):
        if self.__prevTake in ActiveTake.ls():
            hou.hscript("takeset %s" % self.__prevTake)

    def name():
        """ returns: the current set take name. """
        return hou.hscript("takeset")[0].strip()

    def ls():
        """ returns: a list of all available take names. """
        return hou.hscript("takels")[0].split()

proper Take integration would be nice. thought at the moment we don't rely
on it in the studio.

More information about the Sidefx-houdini-list mailing list