Jump to content

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


DocWhite

Recommended Posts

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
Link to comment
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()

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...