Jump to content
Sign in to follow this  
DocWhite

Launch Houdini (with UI) and create geo nodes from Python script

Recommended Posts

DocWhite    0

Hello, what I would like to do is very simple, just for an exercise. I would like to run Houdini from a Python script using the hou module. What I am trying to get working is something like:

import sys
import subprocess
sys.path.append('/opt/hfs15.0.244.16/houdini/python2.7libs')

import hou

hou.hipFile.load(file_name='/home/ramon/hello.hipnc')
sf_geo  = hou.node('/obj').createNode('geo')

But I get no UI. I could do subprocess.Popen(['houdinifx', '/path/to/hipfile.hpnc']) but it creates deatached from the python script. Maybe should I create it first through shell (subprocess.Popen) and then load it using hou.hipFile? and start playing with it inside the python script? I would like to have a self-contained example. Just a python file that the user just runs like python script.py no more.

 

Thanks and sorry for the stupid question.

 

EDIT:

I think I found out what I was looking for... haha... now i can compile vfls using Popen subprocesses and import them afterwards and doing everything in a self-contained file. cool.

import sys
import subprocess
sys.path.append('/opt/hfs15.0.244.16/houdini/python2.7libs')
import hou
hou.hipFile.save(file_name='/home/ramon/hello.hipnc')
hou.hipFile.load(file_name='/home/ramon/hello.hipnc')
sf_geo  = hou.node('/obj').createNode('geo')
hou.hipFile.save(file_name='/home/ramon/hello.hipnc')
subprocess.Popen(['houdinifx', '/home/ramon/hello.hipnc'])
Edited by DocWhite

Share this post


Link to post
Share on other sites

Have you had a look at Hython? Comes installed with Houdini.

Example:

 

in the shell:

hython script.py


script.py contents:

import shutil


#copy hip template into another directory

newfile = ‘/path/to/my/hip/file/newhipfile.hip’
shutil.copy('/dir/file.hip', newfile)

hou.hipFile.load(newfile)
hou.node("/path/to/driver").pressButton()

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×