Skip to content

Instantly share code, notes, and snippets.

@crydalch
Created January 30, 2012 08:49
Show Gist options
  • Save crydalch/1703408 to your computer and use it in GitHub Desktop.
Save crydalch/1703408 to your computer and use it in GitHub Desktop.
Count Nodes
# A Houdini shelf tool to count the total number of nodes in the current file.
# Opens up a small dialogue window to select the node to count under.
# You can get a nice Python icon by pointing the Icon parameter to $HFS/houdini/help/icons/large/MISC/python_official.png
def countNodes(count, nodes):
for n in nodes:
count += 1
if n.allSubChildren():
countNodes(count, n.allSubChildren())
return count
selNodeName = hou.ui.selectNode(initial_node=hou.node('/obj'))
# Instead of getting annoying error messages when 'Clear' is poked in the menu, quit the script
if not selNodeName:
# Might be a cleaner, sanctioned way to do this in Houdini with the hou module...
raise SystemExit
selNode = hou.node(selNodeName)
numNodes = 0
if selNode.allSubChildren():
numNodes = countNodes(numNodes,selNode.allSubChildren())
msg = 'Nodes under %s: %i' %(selNodeName,numNodes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment