Hi,
Is there a way to get a list of event handlers added to a pdg node (similar to eventCallbacks() method of hou.node) or to store some unique id of pdg event handler object to access it after recook of the node that added this handler to be able to remove it?
I tried getting object address using python id() function, storing it to an integer spare parameter and then reading an object from this parameter using ctypes.cast() however it turned out that object id of the event handler changes each time after node recooks so this trick didn't work.
access to pdg event handlers added to the node
2824 7 4- AndriiFroloff
- Member
- 10 posts
- Joined: June 2018
- Offline
- chrisgreb
- Member
- 603 posts
- Joined: Sept. 2016
- Offline
- AndriiFroloff
- Member
- 10 posts
- Joined: June 2018
- Offline
- AndriiFroloff
- Member
- 10 posts
- Joined: June 2018
- Offline
I've tested this new method. It works, however it introduced a new bug. If this method is called within a node, workitems are generated but not displayed in the node interface. In some cases, workitems aren't generated at all on the first run of dirty&cook, only generated on the second run.
Video attached, test cooking of simple processor with and without .removeAllEventHandlers()
houdini 17.5 build 350
Windows 7 SP1
Video attached, test cooking of simple processor with and without .removeAllEventHandlers()
houdini 17.5 build 350
Windows 7 SP1
- chrisgreb
- Member
- 603 posts
- Joined: Sept. 2016
- Offline
- AndriiFroloff
- Member
- 10 posts
- Joined: June 2018
- Offline
Thanks, looking forward to your success. Also if this task turns out to be hard to implement and is not high-priority, maybe you could suggest some temporary trick that is better than my current solution (at least that wouldn't require a manual reset each time and that would allow updating event handler function without reloading a hip-file)
My current solution:
There is a toggle spare parameter ‘event_handler_added’ that must be set to zero (for each node that use event handler) after hip file load.
#event handler adder code in python processor:
event_handler_added = event_handler_added_parm.evalAsInt()
if not event_handler_added:
—-# if zero, assuming this is the first run therefore no event handlers added yet
—-handler = self.addEventHandler(selected, pdg.EventType.UISelect)
—-event_handler_added_parm.set(1) # set flag to 1 to avoid further adding after recook
My current solution:
There is a toggle spare parameter ‘event_handler_added’ that must be set to zero (for each node that use event handler) after hip file load.
#event handler adder code in python processor:
event_handler_added = event_handler_added_parm.evalAsInt()
if not event_handler_added:
—-# if zero, assuming this is the first run therefore no event handlers added yet
—-handler = self.addEventHandler(selected, pdg.EventType.UISelect)
—-event_handler_added_parm.set(1) # set flag to 1 to avoid further adding after recook
Edited by AndriiFroloff - Aug. 22, 2019 02:36:55
- Andrew Graham
- Member
- 150 posts
- Joined: Feb. 2009
- Offline
Being able to list all event handlers for a graph and for nodes would be useful to selectively remove a handler of a certain type / name.
Without being able to list handlers its also not possible to determine if a handler needs to be added for some process.
Without being able to list handlers its also not possible to determine if a handler needs to be added for some process.
Edited by Andrew Graham - Sept. 8, 2019 05:20:40
https://openfirehawk.com/ [openfirehawk.com]
Support Open Firehawk - An open source cloud rendering project for Houdini on Patreon.
This project's goal is to provide an open source framework for cloud computing for heavy FX based workflows and allows end users to pay the lowest possible price for cloud resources.
Support Open Firehawk - An open source cloud rendering project for Houdini on Patreon.
This project's goal is to provide an open source framework for cloud computing for heavy FX based workflows and allows end users to pay the lowest possible price for cloud resources.
- chrisgreb
- Member
- 603 posts
- Joined: Sept. 2016
- Offline
AndriiFroloff
Thanks, looking forward to your success. Also if this task turns out to be hard to implement and is not high-priority, maybe you could suggest some temporary trick that is better than my current solution (at least that wouldn't require a manual reset each time and that would allow updating event handler function without reloading a hip-file)
My current solution:
There is a toggle spare parameter ‘event_handler_added’ that must be set to zero (for each node that use event handler) after hip file load.
#event handler adder code in python processor:
event_handler_added = event_handler_added_parm.evalAsInt()
if not event_handler_added:
—-# if zero, assuming this is the first run therefore no event handlers added yet
—-handler = self.addEventHandler(selected, pdg.EventType.UISelect)
—-event_handler_added_parm.set(1) # set flag to 1 to avoid further adding after recook
Sorry for the late reply. Can't you just store the handler on the pdg node? IE:
if not hasattr(self, 'handler'): def selected(ev): print('HANDLE' +str(ev)) self.handler = self.addEventHandler(selected, pdg.EventType.UISelect)
-
- Quick Links