kiryha Posted February 22, 2018 Share Posted February 22, 2018 How to filter node.children() output so it will return nodes only of the specified type (vopsurface, for example) Currently, I do it with a procedure: def extractVop(listOfChildrens): for node in listOfChildrens: if node.type().name() == 'vopsurface': return node But probably there is more elegant way like node.children().type('vopsurface') Quote Link to comment Share on other sites More sharing options...
f1480187 Posted February 22, 2018 Share Posted February 22, 2018 (edited) This is the proper way, I think. It is commonly used in $HH/python2.7libs to filter nodes by type: https://pastebin.com/EnmhzJKj You can use list comprehensions to make it one-liner: vops = [c for c in node.children() if c.type().name() == 'vopsurface'] Edited February 22, 2018 by f1480187 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.