I've created an HDA with a stroke node inside, with the Node default state set to stroke.
I have some projection geometry that needs to update its size every time the user changes the radius of their stroke, so, I have a Python command in the callback script entry for stroke_radius.
This is called no problem if stroke_radius is changed directly on the stroke_radius parameter - but, if the user changes radius size by holding shift and dragging left/right in the viewport, the callback script does not fire, despite the stroke_radius value changing in the float field, and in preview size in viewport.
Is this a bug, or expected behavior? Any workarounds you can think of?
stroke_radius callback script not called when radius changed
1918 2 2- mtf
- Member
- 17 posts
- Joined: 9月 2012
- Offline
- Alexey Vanzhula
- Member
- 538 posts
- Joined: 12月 2006
- Offline
- mtf
- Member
- 17 posts
- Joined: 9月 2012
- Offline
Thanks for the suggestion. I tried both of the following:
Add a spare param, a float called radius_hack.
Set its value to a python expression: hou.parm(“stroke_radius”).evalAsFloat()
Added a callback script to it: print(“was called”)
If I change the “real” radius stroke, either by changing it's float value or altering it in viewport, “was called” is not printed. As expected, it is printed if I move the slider for radius_hack.
I also tried setting the Python expression of radius_hack to:
hou.parm(“stroke_radius”).evalAsFloat()
import time
print(time.time())
Perhaps this is what you meant. This works, however, when I am drawing a stroke it is called over and over. Since my callback is a caching function that runs somewhat slowly, it's untenable to have it called repeatedly during draw, since it slows things down massively.
EDIT:
I ended up getting something pretty acceptable by doing the following:
Make a spare invisible float param called “last_radius”
Set its value to that of “stroke_radius” on poststroke
On prestroke, check if “last_radius” != “stroke_radius”, and if so, blow the cache
Add a spare param, a float called radius_hack.
Set its value to a python expression: hou.parm(“stroke_radius”).evalAsFloat()
Added a callback script to it: print(“was called”)
If I change the “real” radius stroke, either by changing it's float value or altering it in viewport, “was called” is not printed. As expected, it is printed if I move the slider for radius_hack.
I also tried setting the Python expression of radius_hack to:
hou.parm(“stroke_radius”).evalAsFloat()
import time
print(time.time())
Perhaps this is what you meant. This works, however, when I am drawing a stroke it is called over and over. Since my callback is a caching function that runs somewhat slowly, it's untenable to have it called repeatedly during draw, since it slows things down massively.
EDIT:
I ended up getting something pretty acceptable by doing the following:
Make a spare invisible float param called “last_radius”
Set its value to that of “stroke_radius” on poststroke
On prestroke, check if “last_radius” != “stroke_radius”, and if so, blow the cache
Edited by mtf - 2020年8月11日 23:19:42
-
- Quick Links