Jump to content

Dummy Python Q.: How to start Pre-render script written in Python


stass3d

Recommended Posts

Hi All!

I writing a small snippet, which must create a directory for redner ouput path, if it isn`t exist.

Also I have a script:

import os
import hou

cnode = hou.pwd()
str_nodePath = cnode.path()
str_outputPath = hou.ch(str_nodePath+'/dopoutput')
str_path = os.path.dirname(str_outputPath)
print	>> sys.stdout, str_path

if not os.path.exists(str_path):
	os.makedirs(str_path)

RThe script is saved on $HIP/scriptname.py path.

I have 2 questions:

1. What i need to write in Pre-Render Script Parameter of the ROP?

Something like: python $HIP/scriptname.py or?

2. How should I transfer the current ROP to the script?

Link to comment
Share on other sites

hmm

maybe you should transfer you currently selected node, which would be you ROP -

	net = hou.node("/out")
	selected = net.selectedChildren()[0]

(in 9.1.244 build selectedChildern() not yet implemented!)

and this would be the argument of your function you written. and then you define your function in Python Source Editor and then easily execute it in pre-render script parameter.

Link to comment
Share on other sites

hmm

maybe you should transfer you currently selected node, which would be you ROP -

	net = hou.node("/out")
	selected = net.selectedChildren()[0]

(in 9.1.244 build selectedChildern() not yet implemented!)

and this would be the argument of your function you written. and then you define your function in Python Source Editor and then easily execute it in pre-render script parameter.

This is not what I really want.

If I write this on Hscript, I must just query current node, like this:

set SOP = `oppwf()`

If I understand right, the render scripts must be node related.

But I dont understand the right syntax.

Link to comment
Share on other sites

Not sure if this is the best way to do it, but what I would do is write your scrips as a function which you then import into houdini, or add to the session module.

For example, if I add this to the session module:

def poke():
    hou.ui.displayMessage(hou.node(".").name())

I can then put this into the Pre-Render Script:

hou.session.poke()

and it will show the name of the render node before starting the render.

The way we do it over here is to have all our common functions like that in a separate file which we then import in the 456.cmd (or py), using simply

import ourmodule

(or in the case of 456.cmd: python -c "import ourmodule" )

Then, in houdini, you can access any of your functions using ourmodule.functionname().

Cheers,

-z

Edited by anakin78z
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...