Python: Context Option Events?

   2260   3   1
User Avatar
Member
240 posts
Joined: Oct. 2014
Offline
Does the Python API let us tap into any events specific to Context Options? Hoping there is an event for when context option values are set.
- Tim Crowson
Technical/CG Supervisor
User Avatar
Staff
4438 posts
Joined: July 2005
Offline
There are two very different cases of context options. One case is the “global” context options set through the Edit -> Context Options dialog. These are set using the hou.setContextOption method. These values are available anywhere in Houdini at any time.

For this type of context option, it would be possible to implement a callback when they change. Even right now you can modify/replace the edit context options dialog code, or monkey patch the hou.setContextOption method to know whenever any of these values are changed. But this is obviously not as clean as a real callback mechanism, and there is already an RFE for improving this.

The other case is “network” context options which are set by nodes in the LOP network (Edit Context Options, Add Variant, For Each all set one or more context options). These options are only created when cooking those nodes, and the values are only available to their inputs nodes while those input nodes are being cooked by the downstream node. A Begin Context Options Block node can further limit the “scope” of these network context options.

For changes to this type of context option there will never be a callback. The only entity that has any reason to know when such an option changes are the inputs to the node setting the value, and these nodes are already “notified” (by way of being cooked) when there are changes to any options relevant to them.
User Avatar
Member
240 posts
Joined: Oct. 2014
Offline
mtucker
For this type of context option, it would be possible to implement a callback when they change. Even right now you can modify/replace the edit context options dialog code, or monkey patch the hou.setContextOption method to know whenever any of these values are changed. But this is obviously not as clean as a real callback mechanism, and there is already an RFE for improving this.

That's exactly what I was curious about. This is great to hear. Thanks, Mark!
Edited by Tim Crowson - Dec. 6, 2020 12:03:59
- Tim Crowson
Technical/CG Supervisor
User Avatar
Member
240 posts
Joined: Oct. 2014
Offline
I see 18.5.426 added the following:

Added the ability to register callbacks to run when global context options are changed.

Any info or docs available on how to implement this?
Edited by Tim Crowson - Dec. 30, 2020 13:47:01
- Tim Crowson
Technical/CG Supervisor
  • Quick Links