View Full Version : Returning list of all nodes named [x]
02-01-2011, 01:35 AM
Ok the subject says it all.. I've looked around for this simple thing but can't find what command to use.. Cheers!
btw, it's a colorbuffer node..
02-01-2011, 08:29 AM
02-01-2011, 09:03 AM
I'm in the final throws of finishing up a ToolPack which includes a really powerful filter and search setup / UI for exactly this sort of thing. There's a Beta version of the code up on my blog if you want to have a look:
The Filtercode is an intersection filter so you can mix mutliple filters to find exactly what you want, filters are currently based on nodeType, nodeAttributes & nodeNames ie, node of type colourbuffer, with name search params of 'xxx','fff'. Of course you can do it in a couple of lines of Python too:
import maya.cmds as cmds
return[node for node in nodes if re.search(name,node.split('|')[-1])]
then the call would be something like:
you can also pass in a list of nodeTypes here, and multiple namePattern searches separated by |
If you do download the Beta I'd love some feedback, hopefully this will go out later this month
02-01-2011, 11:28 AM
Hi Andy, ignoring the fact that the ls command alone can already do all this, is using "|" as a separator a sensible idea...? the "|" character is used as the DAG path separator, meaning if someone wanted to search for all "group" items on the ROOT using: "|group", or all instances of "*arm|hand|finger*" they couldn't...?
02-01-2011, 12:24 PM
This is just a hacked up example, and yes, the ls cmd can do it, but the regEx module is way more flexible as a search method, just personal preference I guess.
The '|' is a special character to the regularExpression module, it's basically it's notation of an OR. In the example above I'm stripping the paths off and only processing nodeNames, no dag paths.
You can match to | but you'd have to do something like the following, using the \ to turn the | back to a normal character in the search.
02-01-2011, 12:24 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.