I'm writing a SOP which sets one of its parameters (call it “foo”) with setInt() when it cooks. I see the value update immediately in the parameter editor. However, if another parameter has an expression which references it (e.g., ch(“foo”) ), the display of the numeric value of the expression is not updated until I do something like change the frame. I have confirmed that the expression is actually evaluating to the correct value in my SOP, even though the display is incorrect. How do I make Houdini update the value of the expressions when I change the parameter?
Is having an “output parameter” like this not supported? If so, what is the correct way to achieve a similar effect? I tried a local variable, but it had the same update problem.
HDK: How to make value of expression update?
3993 3 1- amilne
- Member
- 7 posts
- Joined: Oct. 2009
- Offline
- edward
- Member
- 7899 posts
- Joined: July 2005
- Offline
The short answer is: DO NOT SET PARAMETERS WITHIN COOKS!
The long answer is that Houdini's cooking architecture is very much modelled after the idea that you only “pull” data that you want to use. Evaluation should not cause side effects. Here's one explanation of this idea: http://en.wikipedia.org/wiki/Functional_programming [en.wikipedia.org] … In many ways, Houdini can be viewed as a graphical functional language.
The correct method of doing this for your SOP to create some attribute on your geometry data from which then someone can they query from the geometry of your SOP (or any SOP downstream from it).
The long answer is that Houdini's cooking architecture is very much modelled after the idea that you only “pull” data that you want to use. Evaluation should not cause side effects. Here's one explanation of this idea: http://en.wikipedia.org/wiki/Functional_programming [en.wikipedia.org] … In many ways, Houdini can be viewed as a graphical functional language.
The correct method of doing this for your SOP to create some attribute on your geometry data from which then someone can they query from the geometry of your SOP (or any SOP downstream from it).
- amilne
- Member
- 7 posts
- Joined: Oct. 2009
- Offline
Thanks for your reply. Setting aside for the moment the issue of actually using the value of the parameter, what I really want to be able to do is to display a calculated value to the user. So, as they tweak some parameter, they can immediately see the effect on the calculated value instead of having to try to infer it from the way the output geometry changes.
I can use addMessage to display the value when the user middle-mouses over the node, but then it's not visible while they're tweaking the parameter; it requires some extra clicks. It would be so much more convenient if I could display the calculated value in the parameter editor right next to the parameter that affects it.
An example of what I'd like to do is the DOP Network. It has a timestep parameter which contains the expression ch(“timescale”)/(ch(“substep”)*$FPS) The user tweaks the timescale and substep attributes, and sees the effect on the timestep attribute, which is what the node actually uses internally. Additionally, if they really want to, they can delete this expression and set the timestep explicitly. However, my calculation is too complex to put in an expression (it involves reading some files off disk), so I can't do it this way.
It sound like the only correct way to do this is to use two nodes. The first calculates the value and puts it in a detail attribute. The downstream node can then display this value in a parameter using the “detail” expression function. Then I'd have to put both nodes in a subnetwork so that I could display both parameters to the user on a single node. But this is really cumbersome.
I can use addMessage to display the value when the user middle-mouses over the node, but then it's not visible while they're tweaking the parameter; it requires some extra clicks. It would be so much more convenient if I could display the calculated value in the parameter editor right next to the parameter that affects it.
An example of what I'd like to do is the DOP Network. It has a timestep parameter which contains the expression ch(“timescale”)/(ch(“substep”)*$FPS) The user tweaks the timescale and substep attributes, and sees the effect on the timestep attribute, which is what the node actually uses internally. Additionally, if they really want to, they can delete this expression and set the timestep explicitly. However, my calculation is too complex to put in an expression (it involves reading some files off disk), so I can't do it this way.
It sound like the only correct way to do this is to use two nodes. The first calculates the value and puts it in a detail attribute. The downstream node can then display this value in a parameter using the “detail” expression function. Then I'd have to put both nodes in a subnetwork so that I could display both parameters to the user on a single node. But this is really cumbersome.
- edward
- Member
- 7899 posts
- Joined: July 2005
- Offline
-
- Quick Links