Add Null Node shortcut/script?

   8341   15   5
User Avatar
Member
39 posts
Joined: 7月 2014
Offline
Hello,

Does any have a script or a shortcut to create a new Null Node and connect it to the currently selected node? Would be really handy.

Cheers
User Avatar
Member
319 posts
Joined:
Offline
def createNull():
sel = hou.selectedNodes()
sel.createOutputNode(“null”)


That in a shelf button would do it. Not sure how much time its actually saving you though!

Maybe you could then map the shelf tool to a shortcut key…
User Avatar
Member
39 posts
Joined: 7月 2014
Offline
Thanks a lot Dean! Yea I just want to assign it to a short so I can create a null quickly.

Thanks again
User Avatar
Member
39 posts
Joined: 7月 2014
Offline
I've made a shelf tool and placed the script in there but when I select and node and run the script, nothing happens?
User Avatar
Member
319 posts
Joined:
Offline
Oh yeah, hehe, get rid of the def() line, you don't need it, its just because i tested it in the hou.session() module.
User Avatar
Member
319 posts
Joined:
Offline
So your shelf tool script would literally just be:-

sel = hou.selectedNodes()
sel.createOutputNode(“null”)
User Avatar
Member
39 posts
Joined: 7月 2014
Offline
Great, Thanks
User Avatar
Member
49 posts
Joined: 9月 2013
Offline
Hey sessionbeer,

just saw your post and this is something I had been working on a long while ago and following is the scriot i came up with:

node = hou.pwd()
for i in hou.selectedNodes():
if hou.nodeTypeCategories().keys():
### Above function lets you call this function on any context ###
dir = i.parent().path() + ‘/’
selNodeName = i.name()
nodeinfo = i.type().name()
otherName = hou.ui.readInput('Name the null', buttons'OK', ‘CANCEL’), initial_contents='_')
nullnode = hou.node('/%s'%dir).createNode('null', ‘OUTPUT%s’%otherName)
selNodePos = i.position()
nullnode.setColor(hou.Color( ))
### Setting node position ###
nullnode.setPosition(hou.Vector2(selNodePos,selNodePos-1))
nullnode.setInput(0,i)
i.setSelected(False)
nullnode.setSelected(True)
### Setting render and display flags for respective contexts ###
try:
nullnode.setDisplayFlag(True)
nullnode.setRenderFlag(True)
except:
nullnode.setDisplayFlag(True)

This will let you create nulls with the default name set to OUTPUT, and you can drop down nulls in any context you wish to, like sops, vops, cops, chops, etc except shops and selected as many nodes as you want at once to drop down nulls

but this a littlte fancy as it brings a liitle ui dialogue box where you can enter the name you want for the node.


Hope this helps!

Cheers!

-Yash
User Avatar
Member
49 posts
Joined: 9月 2013
Offline
Sorry i forgot to mention, if you want a quicker shortcut comapred to selecting the node and then pressing the shelf tool button,

in the shelf tool where you have this script, right click on the tool>edit tool>hotkeys>global>edit

here you can assign any shortcut you want for executing the script for eg: mine is Ctrl+Enter, you can type in whatever you are comfortable with

So now when you assign the hotkey, just select the node or nodes you want to create nulls for and hit the hotkey, it will execute the script as coded!!

Cheers!

-Yash
User Avatar
Member
676 posts
Joined: 2月 2017
Offline
Hey MrReedSmith,

thanks for sharing your script! i would like to use it in Houdini 16.0557, but it gives me a “Syntax error(s) detected” message. do you know how to make it work in the current Houdini version?

Thanks alot
and cheers
CYTE
User Avatar
スタッフ
4435 posts
Joined: 7月 2005
Offline
It might be the emoji in the middle of the code… when I copy/pasted that line, the emoji got removed completely. It needs to be replaced with “”.

Edit: Gah. I mean replaced with ":("
Edited by mtucker - 2017年4月26日 12:53:38
User Avatar
Member
7734 posts
Joined: 9月 2011
Offline
MrReedSmith
node = hou.pwd()
for i in hou.selectedNodes():
    if hou.nodeTypeCategories().keys():
### Above function lets you call this function on any context ###
        dir = i.parent().path() + '/'
        selNodeName = i.name()
        nodeinfo = i.type().name()
        otherName = hou.ui.readInput('Name the null', buttons=('OK', 'CANCEL'), initial_contents='_')
        nullnode = hou.node('/%s'%dir).createNode('null', 'OUTPUT%s'%otherName[1])
        selNodePos = i.position()    
        nullnode.setColor(hou.Color( [0,0,0] ))
### Setting node position ###
        nullnode.setPosition(hou.Vector2(selNodePos[0],selNodePos[1]-1))
        nullnode.setInput(0,i)
        i.setSelected(False)
        nullnode.setSelected(True)
### Setting render and display flags for respective contexts ###
        try:
            nullnode.setDisplayFlag(True)
            nullnode.setRenderFlag(True)
        except:
            nullnode.setDisplayFlag(True)
User Avatar
Member
676 posts
Joined: 2月 2017
Offline
Hey jsmack,
sry for answering so late. That was it! Thank you!
Your script is very handy, thanks for sharing!
Cheers
CYTE
User Avatar
Member
59 posts
Joined: 11月 2014
Offline
jsmack
MrReedSmith
hey if we need the default node color how can we get that.
i used a
c =hou.Color()
c.setHSV([205,20,87]) 
in place of
nullnode.setColor(hou.Color([0,0,0]))
or
by deleting that code we are getting default code
instead of that how can we get a default color of that/null node, got basics of python but I need to study and know the houdni python.



in advance thank you so much for your time and consideration for help
Edited by Sweetener - 2019年4月3日 06:08:05
Houdini Fx Artist (Build)
User Avatar
Member
12 posts
Joined: 2月 2018
Offline
Hello,

Guys thank you for that wonderfull piece of python.
However I don't know much about python and I would like to make some more shortcuts but I can't find their names anywhere
Would you mind telling me by what I should replace “nullnode” in your python to get the equivalent on a “Transform SOP”, “copy to points SOP”, “Attribute Wrangle”, “Color SOP”, “Filecache”, “Object Merge” ??

I love how it is in Nuke to press M for merge, C for colorcorrect, K for Copy, T for transform, R for Read, W for Write etc. and I'm really used to it, so I would love to have an equivalent in Houdini because it's so frustrating when you hit T and nothing happens xD

I did it for the “Merge” by replacing “nullnode” by “mergenode” but yeah I'm stuck for all the others pretty much and I have no idea where I can find that answer
User Avatar
Member
191 posts
Joined: 10月 2018
Offline
This is modified from what MrReedSmith posted and works on the first selected node if any are selected. You can modify it and put it in a for loop if you want it to work on all the selected nodes though. Just like was said earlier, put it in a shelf tool and assign it a hotkey.

selection = hou.selectedNodes()

if len(selection) != 0:
    selected = selection[0]
    parent = selected.parent().path() + '/'
    selNodeName = selected.name()
    selNodePos = selected.position()  
    
    node = hou.node('/%s' %parent).createNode('xform')
    
### Setting node position ###
    node.setPosition(hou.Vector2(selNodePos[0], selNodePos[1]-1))
    node.setInput(0, selected)
    selected.setSelected(False)
    node.setSelected(True)
    
### Setting render and display flags for respective contexts ###
    try:
        node.setDisplayFlag(True)
        node.setRenderFlag(True)
    except:
        node.setDisplayFlag(True)

You can find out what the type of each node is by dragging the node from the network pane to a python shell and write “.type().name()” after it like this:

>>> hou.node('/obj/geo1/null1').type().name()
'null'
>>> hou.node('/obj/geo1/transform1').type().name()
'xform'
>>> hou.node('/obj/geo1/merge1').type().name()
'merge'

Then you just need to modify this line and change ‘xform’ to any other node type.
node = hou.node('/%s' %parent).createNode('xform')
  • Quick Links