Jump to content
jon3de

set parm values via python with Expressions inside

Recommended Posts

Currently I wanted to change some rops´s image path parameters with python. I have the problem that python converts my strings with e.g. "$F4" or "$JOB" expressions in it to absolute paths. Can I avoid that? 

e.g. :

c.parm("vm_picture").set("//testDirectory/teststring_$F4.v001.exr")

turns to:

//testDirectory/teststring_0079.v001.exr

How can I set this up with keeping the $JOB or $F expressions in it? is this possible?

 

Share this post


Link to post
Share on other sites

Hmm.. this auto conversion may not be avoidable. The first thing that comes to mind, however, is that you could place your code inside the pre-render event of the ROP. Then your code will evaluate on every frame and still construct the correct filename for that frame.

Edited by Atom

Share this post


Link to post
Share on other sites

What version of Houdini are you using?

It seems to be working on my end..

PYTHON SHELL:
python_shell.gif

PYTHON SHELF:
python_shelf.gif

Or are you doing something differently to execute the Python code?

If not, one possible reason why it is showing as the expanded value is that you have middle clicked your parameter.

Edited by galagast
  • Like 1

Share this post


Link to post
Share on other sites

Thank you for the gifs!

I´m working with 15.5.717

Hm dont know if that makes any difference but i used this method to submit my code.

http://www.tokeru.com/cgwiki/index.php?title=HoudiniPython#Make_a_general_python_input_window

I will try it with the python shelf and with houdini 16.

21 minutes ago, galagast said:

If not, one possible reason why it is showing as the expanded value is that you have middle clicked your parameter.

No, I checked that already.

kind regards

 

EDIT: I checked it via python shelf and there it works! Thank you Jeff. 

Would be interesting whats the problem with this self build python text editor...

 

 

Edited by jon3de

Share this post


Link to post
Share on other sites

That's a cool tip from tokeru!

Seeing that that was the method used, I believe the reason why it gets expanded is because it is using the "exec()" function to evaluate the code.

You can escape it using a backslash like so:

c.parm("vm_picture").set("//testDirectory/teststring_\$F4.v001.exr")


This seemed to work :)

 

  • Like 1

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

×