Jonathan Curiel

Musing from a digital artist point of view.

Maya Script of the Week: Select faces with the same material

Similar to my ZBrush Sculpt of the Day, I’ve decided to give myself one day (more than likely half a day since I’m probably going to do this on the weekends) to come up with a script that will allow you to do something useful in Maya. Today I decided to create a script that will select all the faces on a single mesh that have the same material applied to them. A very handy script I would say. Though Maya does have a “Select Objects with Materials” option in the Hypershade –> Edit menu, it selects everything that has that material. With this script, if you select a single face and run the script, all faces on that single mesh will be selected. Handy if you want to change those faces to another material. It will also select the material in the Hypershade as a bonus in case you want to apply that material to something else.

The script itself could probably have been edited further to be a bit more efficient, but this is just an exercise in trying to put together something quickly that works. Unfortunately I can’t upload .mel files to WordPress so I’ve attached a link here to a Word .doc if you’re interested in checking it out. To run the script, you can easily paste the code to Maya’s Script Editor, save it to your script folder and call as a MEL script command JC_selectFacesSameMat.

     JC_selectFacesSameMat JC_selectFacesSameMat

The way it works is pretty straight forward. The script first finds the Shading Group and Material of the selected face (wanted to be sure that it had both of these in case a Shading Group was shared). Then it tests to see if the other faces on the mesh have the same Shading Group and Material assigned. If so, it add stores those and when it finishes iterating through all the faces, will select only the faces that match.

Enjoy, I hope you find this useful.

About these ads

One Response to “Maya Script of the Week: Select faces with the same material”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: