View Full Version : Selection by name of groups only

11 November 2012, 11:15 AM

I've been struggling for a while with what I hope is quite a basic thing to do. I'm trying to select any groups in a scene with a certain name to use in my mel script.

what I'm doing at the moment is this

if (`objExists GEOMETRY`)
select -r "*GEOMETRY" ;
rest of the script...

The trouble is I'd like to only select groups called GEOMETRY and not any old objects that have that in the name for safety reasons. Ideally the script then performs actions on the hierarchy within the selected GEOMETRY groups. :)

If I take away the "*GEOMETRY" and replace it with just "GEOMETRY" it warns me that there's more than one thing called that and stops.

I hope this makes sense as I'm not greatly experienced with scripting, but just trying to piece things together with lots of forum searching and googleing.

Thanks for any advice

11 November 2012, 12:36 PM
You can get a bit more control over what you add to your list using ls with the type keyword.'*_geometry', type='transform')'*_geometry', type='shape')'*_geometry', type='mesh')


ls -type "transform" "*_geometry";
and so on...

You might rewrite your code something like this...
geo_groups ='*_geometry', type='transform')
if geo_groups: geo_groups


string $geo_groups[] = `ls -type "transform" "*_geometry"`;
select $geo_groups;


11 November 2012, 02:29 PM
thanks very much for the quick reply. I'll give these a go. :)

12 December 2012, 04:08 AM
I just realized it may not have been clear to some people that my last post contained both python and mel examples, to demonstrate how it could be done in python _or_ mel, in that order. Sorry for the confusion.


CGTalk Moderation
12 December 2012, 04:08 AM
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.