Search the Community
Showing results for tags 'oncreated'.
-
Hey Guys, Still quite new to Python, hoping someone can help point me in the right direction on this that I've been grappling with for a while now. I have a simple filecache .hda that I'd like to change color if it can/can't find the cache on disk. I've been able to use hou.ui.addEventLoopCallback() to continuously track and check the file parameter to see if the cache exists, and the color changing now works as expected. Where I'm having trouble is removing the event loop when the .hda is deleted from the node graph. An error pops up because Houdini is still trying to access the deleted node. I've been trying to look for a way to use the OnDeleted event handler, or hou.nodeEventType.BeingDeleted, but no luck yet and I feel out of my depth with my limited python experience. The .hda is attached, and there's a preview of the code below. Any help would be appreciated! custom_filecache.hda ####PythonModule#### import os import hou def nodeColor(kwargs): node = kwargs["node"] def colorCallback(): filepath = node.evalParm("file") if(os.path.exists(filepath)): node.setColor(hou.Color((0.0, 0.8, 0.0))) node.setComment(filepath) node.setGenericFlag(hou.nodeFlag.DisplayComment,True) else: node.setColor(hou.Color((0.8, 0.0, 0.0))) node.setComment("File not found") node.setGenericFlag(hou.nodeFlag.DisplayComment,True) startCallback(colorCallback) #adding this code below crashes Houdini when hda is deleted #node.addEventCallback([hou.nodeEventType.BeingDeleted], endCallback(colorCallback)) def startCallback(callback): hou.ui.addEventLoopCallback(callback) def endCallback(callback): hou.ui.removeEventLoopCallback(callback) ####OnCreated#### kwargs["node"].hdaModule().nodeColor(kwargs)
-
Hi, I have an HDA (sop) that contains a different HDA (rop). The problem I have is that I need both of them to run a OnCreated event, but it seems to run only when user creates the node, not when it gets created as a part of a different hda (both have the OnCreated working, when I just create them separatelly). Does anyone have a solution for this? Thanks Martin Running: Houdini 17.5, Linux
- 3 replies
-
- hda
- event handler
-
(and 3 more)
Tagged with: