The guide geo does in fact display when I enter the tool. I does not update, however, when the guide geometry changes even though:
"If you get the geometry from a SOP node using SopNode.geometry, the resulting Geometry object is a live, read-only reference to the node’s output. If the node’s output changes (for example, because it is driven by parameters on your asset), the contents of the Geometry object automatically update.
I'm not seeing this behavior and was wondering if I was doing something incorrect. My geometry is static and does not update unless I re-enter the tool (or force a re-cook in one of the other events).
I would like the guides to update as the guide geometry updates. Thanks,
rkopinsky I'm working with a custom python state in H17. I've setup guide geometry in the HDA and reference it in the onEnter method as the docs suggest:
The guide geo does in fact display when I enter the tool. I does not update, however, when the guide geometry changes even though:
"If you get the geometry from a SOP node using SopNode.geometry, the resulting Geometry object is a live, read-only reference to the node’s output. If the node’s output changes (for example, because it is driven by parameters on your asset), the contents of the Geometry object automatically update.
I'm not seeing this behavior and was wondering if I was doing something incorrect. My geometry is static and does not update unless I re-enter the tool (or force a re-cook in one of the other events).
I would like the guides to update as the guide geometry updates. Thanks,
Here you go. It takes any curve as input (a line SOP with several points will work just fine). The UI should produce arrows at every point. Thanks for the assist.
Ok I think I found the problem… The drawable is not a node in the scene but just an object referencing the geometry. So when the node's scale parm is modified, it doesn't get refreshed since nothing is pulling on it.
The workaround I found is to add a callback to the scale parm to cook the node:
I guess I'm confused then on how to make the guide geometry live, as per the help. For example if the input curve is animated and I scrub the timeline the arrows do not update appropriately. I don't know where I would call the cook() method to accomplish this.
Actually the code from the help throws an error when pointing to a node, specifically:
The documentation sample seems wrong, `hou.Drawable` takes either an enum or a geometry, not a node.
Using a node callback to react to scale change is another way to recook but the callback is not called on parms driven with an animation or an expression. I also tried with a playbar callback but for some reason the node won't recook either…
Here's my test code:
classMyState(object):def__init__(self,state_name,scene_viewer):self.state_name=state_nameself.scene_viewer=scene_viewerself._guide=Noneself._node=Nonehou.playbar.addEventCallback(self.onPlaybarEvent)# Handler methods go heredefonPlaybarEvent(self,event_type,frame):print'onPlaybarEvent ',event_type,frame#self._node.parm('scale').eval()#self._node.node('Guide').cook(force=True, frame_range=(frame,frame))self._node.node('Guide').cook(force=True)defonNodeEvent(self,event_type,**kwargs):ifevent_type!=hou.nodeEventType.ParmTupleChanged:returntry:ifkwargs['parm_tuple'][0].name()=='scale':kwargs['node'].node('Guide').cook()except:printkwargs['parm_tuple']defonExit(self,kwargs):try:hou.playbar.removeEventCallback(self.onPlaybarEvent)except:passkwargs["node"].removeEventCallback([hou.nodeEventType.ParmTupleChanged],self.onNodeEvent)self._node=NonedefonEnter(self,kwargs):node=kwargs["node"]inputs=node.inputs()#setup guidegeo=node.node("Guide").geometry()#geo = node.node("Guide")self._guide=hou.Drawable(self.scene_viewer,geo,self.state_name+"_guide")self._guide.enable(True)self._guide.show(True)self._node=nodenode.addEventCallback([hou.nodeEventType.ParmTupleChanged],self.onNodeEvent)
I've been working with the new python states recently and also found quite a few issues with the examples from the docs. Easiest way I've found to get my guides live updating is to use a null with the copy geometry parameter toggled off then merge that in above your actual output node.
(Excuse my ASCII node graph)
HDA network Guide geo | | | GUIDES_OUT (point your Drawable to the .geometry() from this node) | | | null (copy geometry off) | / | / | / merge | OUT
Wiring it up like this will cause the guide geo branch to cook when the hda gets evaluated so you don't have to manually force cook any nodes with callbacks.