MikeRhone Posted November 17, 2011 Share Posted November 17, 2011 Hey all. I'm trying to evolve a procedure I found here: . Basically, I want to be able to return a list of objects based on their name. I'm pretty new to OOP, but I know MEL well. Is this the standard way to select by name/type in Houdini through Python? My code: def printSearch(term): li = [] for n in hou.node('/').allSubChildren(): if n.name().startswith(term): #print n.path() li.append(n.path) printSearch("Rock") print li Error: Traceback (most recent call last): File "tool_5", line 11, in <module> NameError: name 'li' is not defined Quote Link to comment Share on other sites More sharing options...
tmdag Posted November 17, 2011 Share Posted November 17, 2011 (edited) `li` not a global attribute, it's only inside definition if you for eg. create li before def then it will work li = [] def printSearch(term): etc.. Edited November 17, 2011 by tmdag 1 Quote Link to comment Share on other sites More sharing options...
MikeRhone Posted November 17, 2011 Author Share Posted November 17, 2011 Ack... That is totally it. Thanks a ton Albert! 1 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.