Passing a script into HYTHON?

   3040   2   0
User Avatar
Member
12 posts
Joined: Feb. 2012
Offline
Hi all, I have a script that can do some cooking and timing in Houdini. However, right now I can only run it in UI mode. Is it possible to run my script using the Houdini command line? Something like:

hython “somefile.hip” -script “somescript.py”

Basically, I'm trying to find a way to get hython/houdini to run a script after loading a file, all automated.
User Avatar
Member
30 posts
Joined:
Offline
in some cases, it might work to make your script be responsible for loading the hip file with a wrapper function. generally how we do things here for farm export stuff.

eg

/path/to/hython /path/to/script.py -i /path/to/hip.hip

and if your python script is structured thusly:
from optparse import OptionParser

def do_the_thing():
    # do amazing things here
    pass

if __name__ == "__main__":
    # this gets run when called via the commandline
    # parse commandline arguments here and pass to the main function
    parser = OptionParser(usage)
    parser.add_option("-i", "--hip", dest="hipfile", help="path to .hip file")
    # load the scene
    hou.hipFile.load(options.hipfile)
    # now do the thing with the scene
    do_the_thing()

cheers,
chrisg
User Avatar
Member
12 posts
Joined: Feb. 2012
Offline
Hi there, thank you for the response. Basically what I'm trying to do is time some operations inside a specific file. I'll try your suggestion, thank you.
  • Quick Links