rich_lord Posted April 30, 2017 Share Posted April 30, 2017 Hello everyone I have a lot of nodes in my scene. I'd like to somehow know how many nodes there are that have a name following a particular format. So my nodes are named, "char0", "char1", "char2", ....... ,"char?" Is there a way I can write an expression to count up these nodes? In the example picture the expression should return 4. In practice, I have many more nodes, but the naming convention is consistent. Thanks for any ideas! Quote Link to comment Share on other sites More sharing options...
sandford Posted April 30, 2017 Share Posted April 30, 2017 What about the 'Find Node' option? Gives you a numbered result and a few filters. 1 Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted April 30, 2017 Share Posted April 30, 2017 (edited) You can count all nodes on object level by a specific name using Python. # INPUT node = hou.node("/obj") search = hou.ui.readInput("Find OBJ nodes by name:", buttons=('Search',), title="Count nodes") name = str(search[-1]) # SEARCH obj_nodes = [] for child in node.children(): obj_nodes.extend([child.name()]) match = [x for x in obj_nodes if name in x] count = str(len(match)) # OUTPUT print(match, count) text = count + " nodes found named " + name + "." hou.ui.displayMessage(text, buttons=('OK',), title="Number of nodes") Edited April 30, 2017 by konstantin magnus 1 Quote Link to comment Share on other sites More sharing options...
rich_lord Posted April 30, 2017 Author Share Posted April 30, 2017 Thanks for the tips guys. Both of these solutions work. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.