I have a question about the Viewer Handle Module, namely how to access the current node from the module. Unlike Viewer State, where it is available from almost every event handler from the dictionary (kwargs) as a "Node" key, it does not exist in the Viewer Handle context.
... def onEnter(self, kwargs): self.node = kwargs["node"]
It's basically not necessary if it's just to read the node parameters, since you can bind them and export them to viewer state.
def createViewerHandleTemplate(): ... # Register handle parameters. template.bindParameter(hou.parmTemplateType.Float, name="tx", default_value=0.0) template.bindParameter(hou.parmTemplateType.Float, name="ty", default_value=0.0) template.bindParameter(hou.parmTemplateType.Float, name="tz", default_value=0.0) # Export handle parameters. template.exportParameters(["tx", "ty", "tz"])
For example, there is a way to access it through the "scene_viewer" entry, but I don't get the current node that the handle is bound to (SOP), instead the parent GEO node.
class Handle(object): def __init__(self, **kwargs): ... self.scene_viewer = kwargs["scene_viewer"] self.node = self.scene_viewer.pwd() print(self.node) # geo1
I could now output a list via the children() method and somehow try to access the node I'm looking for. But this seems to be quite undynamic.
Does anyone know a better way?