Python: Context Option Events?
2261 3 1- Tim Crowson
- Member
- 240 posts
- Joined: Oct. 2014
- Offline
- mtucker
- 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.
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.
- Tim Crowson
- 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
Technical/CG Supervisor
- Tim Crowson
- Member
- 240 posts
- Joined: Oct. 2014
- Offline
-
- Quick Links