Jump to content

set parm values via python with Expressions inside


jon3de

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?

 

Link to comment
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
Link to comment
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
Link to comment
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
Link to comment
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
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...