Created
January 30, 2012 08:49
-
-
Save crydalch/1703408 to your computer and use it in GitHub Desktop.
Count Nodes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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