Context Options with variables - How to expand them?

   956   2   1
User Avatar
Member
20 posts
Joined: Dec. 2020
Offline
Hey all, I'm using context options to manage global attributes when working across multiple houdini scenes. I have a context option which has a variable in it, "$F" because its an image sequence.

When I use
`@myFile`
it returns the unexpanded string with "$F" still in the name. This is not expanded in my texture/image nodes when rendering. Is there a way to force the string to be expanded twice?

I would rather avoid using a python parameter to expand the variable, as other users im working with expect to just use `@myFile`.

I would also like to avoid expanding "$F" in the context option itself because then it would need evaluating per frame.

Any ideas? Cheers
User Avatar
Staff
4523 posts
Joined: July 2005
Offline
In your parms, you need to tell Houdini to evaluate the value of the context option as if it were an expression, so the "$F" gets expanded. I put:

`evals(@foo)`

as the parameter in a Font SOP, and then I set the `foo` context option to:

"frame_" + $F

And the output was "frame_22" (or whatever frame I was on).

Unfortunately, this did not seem to introduce a time dependency on my Font SOP, so the node didn't recook when I changed frames. I have submitted this as a bug, because it seems to me that this should just work. But maybe this is a limitation you can work around by some other means.
User Avatar
Member
20 posts
Joined: Dec. 2020
Offline
Thanks mtucker, I tried evals() but it was giving me an 'extra tokens' error, turns out I needed to encapsulate the string with double quotes in the context option like your example, so thank you.

You can give the parameter with the expression a keyframe (Alt+LeftClick) which then evaluates the context option per frame, but it not changing per frame using the regular backticks will break our renders unfortunately, and while its great it works expanding it still means our artists will need to put evals() everywhere they need the context option - which isn't ideal!
  • Quick Links