Viewport Xform Handle manipulation & Python Callback (HDA)

   2235   5   1
User Avatar
Member
147 posts
Joined: Jan. 2016
Offline
I was used to create the "old" handles to my HDAs. But now, for the first time, I need a "realtime" python callback, while user is manipulating the Xform handle.

Should I bind viewport callback to the "oldschool" handle? Should I do that in OnCreated script?

I managed to create a Viewer State for my HDA, create a Xform handle, and I am geting onParmChangeEvent() readings of handle parameters, but so far I did not manage to bind the handle to the object's parm interface. (the Xform always emerges at {0,0,0})


Please, what is the preferred way in this situation?

Thank you very much.
User Avatar
Staff
401 posts
Joined: Feb. 2018
Offline
You should be able to bind a xform handle to your HDA without having to write a viewer state. You can do this by mapping editable parms on your HDA to the xform handle parms from the Handles tab [www.sidefx.com]

With a viewer state, it can be done programmatically with hou.ViewerStateTemplate.bindHandleStatic or hou.ViewerStateTemplate.bindHandle. See documentation [www.sidefx.com] for details. You can also look at this example file for a live demo $HFS/houdini/viewer_states/examples/bend_demo.hip
User Avatar
Member
147 posts
Joined: Jan. 2016
Offline
Marc thank you very much for your answer.

Please, is it possible to get a Python Callback Script called while manipulating the "classic" handle in the viewport? Without writing a custom viewer state?

I did this:
- bind the "classic" handle to a parm
- set Callback Script to that parm

But that Callback Script is called only while editing the parm value in the Parameters Pane (MMB Ladder or keyboard entry, or scroll wheel).
User Avatar
Member
147 posts
Joined: Jan. 2016
Offline
For this case, I will use a classic Handle and hou.nodeEventType.ParmTupleChanged

Thank you very much again.

I am still curious if we can set up an event handler (Python Callback) on those "classic" Handles, but it seems that we can't.
Edited by ikoon - March 25, 2021 18:08:00
User Avatar
Staff
401 posts
Joined: Feb. 2018
Offline
You can't bind a python callback directly to a handle. You can only do this in a python state when binding an handle dynamically. [www.sidefx.com]
User Avatar
Member
147 posts
Joined: Jan. 2016
Offline
Marc, thank you very much for your help.
  • Quick Links