Using Wildcards in Maya
Selecting nodes using wildcards in the Input Box
This tutorial originated on the 3D Animation weblog Set Driven Key.
You may already be familiar with the Input Box in Maya. It's a text field on the status line (on the top right of the screen) where you can type in the name of an object in order to select it. Type in "persp" and hit enter, and the perspective camera will be selected.
(Depending on which version of Maya you are using, the Input Box will look like either of the images below.)
A cool function of the Input Box is the ability to use wildcards (? and *) to select multiple objects at once. This makes it a very handy selection tool.
For instance, let's say you have several hundred objects in your scene that have "post" in their name (post1, post2, post3, postLeft, postRight, etc . . . ) and you want to select them all to apply the same shader to them. Simply type *post* into the Input Box, and Maya will select all the objects that have the word post in them.
Another use for wildcards is when you're trying to select a node whose exact name you can't remember. Maybe you're looking for a particular piece of geometry parented deep within your scene somewhere, but you can't quite remember the name. It's called cyclorama_something. (Sphere? Dome? Card? - you can't remember). Just enter cyclorama* into the text field.
The sky's the limit as far as potential uses. Basically, it's a great tool for tracking down objects that are scattered throughout your scene - either for single nodes whose exact names you can't remember or for multiple objects at once.
Here's a quick guide to using the wildcards:
? - designates a single character variable . So if you enter cube?, you might get back
The ? can appear anywhere in the string. cube?, ?cube, and c?ube are all valid uses.
* - designates a multi-character variable. So if you enter thumb*, you'll get back
You can place the * anywhere in the string. thumb*, *thumb, and th*umb are all valid uses.
Multiple wildcards are allowed in one entry.
eg: If you enter lower*Button? you could get:
The Input Box isn't the only place that you can use wildcards. You can also incorporate them into MEL scripts. eg: select "locator*" ;
In fact, used this way, they are a very powerful tool for creating automated batch processes in your scenes. They also add an extra incentive for keeping consistant naming conventions throughout your projects. If all the characters in your scene follow the same naming convention (perhaps they all have root points named charRoot_name), then it becomes easy to select them all in a script to perform some sort of automated task. All it takes is one line of MEL: select "charRoot_*"
That's it for today!
I hope that you enjoyed the lesson. Feel free to email me with any questions or corrections. For more tips and tutorials, check out my weblog: Set Driven Key.