Skip to content

Instantly share code, notes, and snippets.

@Regnareb
Last active September 17, 2022 12:01
Show Gist options
  • Save Regnareb/a197047f1cf1b4a0731176c99f4bf59c to your computer and use it in GitHub Desktop.
Save Regnareb/a197047f1cf1b4a0731176c99f4bf59c to your computer and use it in GitHub Desktop.
Put that in your houdini pref folder to create a Null connected to the selected node if you click Shift in the graph editor (houdiniXX.X\python2.7libs\nodegraphhooks.py)
import hou
import canvaseventtypes
def follow_flags(parent, child):
if parent.isDisplayFlagSet():
child.setDisplayFlag(True)
if parent.isRenderFlagSet():
child.setRenderFlag(True)
def createEventHandler(uievent, pending_actions):
if isinstance(uievent, canvaseventtypes.MouseEvent) and \
uievent.eventtype == 'mousedown' and \
uievent.modifierstate == canvaseventtypes.ModifierState(alt=0, ctrl=0, shift=1):
selected = hou.selectedNodes()
mousepos = uievent.editor.posFromScreen(uievent.mousepos) - hou.Vector2(0.5, 0.2)
if len(selected) == 1:
parent = selected[0]
child = parent.parent().createNode('null')
child.setName('null_' + parent.name(), unique_name=True)
child.setInput(0, parent, 0)
child.setPosition(mousepos)
follow_flags(parent, child)
return None, True
for parent in selected:
child = parent.parent().createNode('null')
child.setName('null_' + parent.name(), unique_name=True)
child.setInput(0, parent, 0)
position = parent.position()
position[1] = mousepos[1]
child.setPosition(position)
follow_flags(parent, child)
return None, True
return None, False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment