Jump to content

Shelf tools & scripts collection


younglegend

Recommended Posts

 

Hey guys! I'm starting this thread to share few shelf scripts i use and came across, during my houdini journey. Please feel free to add in more!

 

# ADD NODES/OBJECTS TO MANTRA (Customisable)

Select node(s) and click on the script to add it to mantra's force object/matte object etc. You can customise where to add by changing the parameter name (line 22) 

import hou
selection = hou.selectedNodes()
names = [n.name() for n in selection]
my_list = “”
if len(selection) < 1 :
my_list = "nothing selected, please select at least one object"
else:
a=1
for sel in selection:
my_list = my_list + "\n" + "selected object " + str(a) + ":" + sel.name()
a=a+1
hou.ui.displayMessage(my_list, buttons=('OK',))
length = len(selection)
print "Number of nodes selected: " + str(length)
paths = [n.path() for n in hou.node('/out').allSubChildren()
if n.type() == hou.nodeType('Driver/ifd')]
selected = hou.ui.selectFromTree(choices=paths)
mantras = [hou.node(path) for path in selected]
for m in mantras:
m.parm('matte_objects').set(' '.join(n.name() for n in hou.selectedNodes()))
#CHANGE PARAMETER NAME AS REQURIED
print ("Selected mantra nodes : ") + m.name()
new_name=' '.join(names)
hou.ui.displayMessage("( "+ (new_name) + " ) – added to selected mantra(s) matte objects.", buttons=('*OK*',))

 

#SETUP DELAYED LOAD

Select node(s) and execute. It'll create procedural shader and setup all the parameters. Works on all nodes with 'file' parameter.

#function for node variable: return type, description and name
def extract_getTypeName(node):
nodetype = node.type()
description = nodetype.description()
type_name = nodetype.name()
return type_name
#show selection tuple names
selection = hou.selectedNodes()
print len(selection)
my_list = “”
if len(selection) < 1 :
my_list = "nothing selected, please select at least one object"
else:
a=1
for sel in selection:
my_list = "selected object : " + sel.name()
a=a+1
hou.ui.displayMessage(my_list, buttons=('OK',))
#for each object in selection
lenght = len(selection)
print "DONE!"
for i in range(lenght):
#create python variable for selected node
selected = hou.selectedNodes()[i]
if selected:
meshop=hou.node('/shop');
meshop=meshop.createNode('vm_geo_file');
meshop.setName('delayed_load_shop_1', 1)
targetdshop=meshop.path();
meobj=hou.node('/obj')
meobj=meobj.createNode("geo");
meobj.setParms({"shop_geometrypath":targetdshop});
meobj.setName('DELAYED_load_geo_1', 1)
targetfile=selected.parm('file') or selected.parm('sopoutput')
mefile=meobj.node('file1')
meobj.parm("geo_velocityblur").set(1)
meobj.parm("vm_forcegeometry").set(0)
meshop.parm("file").set(targetfile)

 

Edited by kishenpj
Link to comment
Share on other sites

 

#Add Null node by pressing 'N' key

selected_nodes = hou.selectedNodes()
for node in selected_nodes:
parent = node.parent()
name_node_selected = node.name()
null = parent.createNode(‘null’,’OUT_’ +
name_node_selected)
null.setInput(0,node)
macolo = hou.Color((0,0.5,0))
null.setColor(macolo)
pos = node.position()
null.setPosition(pos)
null.move([0,-1])
#flags
null.setSelected(True,True)
null.setDisplayFlag(True)
null.setRenderFlag(True)

Credit-Florian Bard

  • Like 1
  • Thanks 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...