Select Random Faces in Maya with Mel Script

Select Random Faces in Maya with Mel Script

Select random faces in Maya is a very handy mel script tool. Since Maya doesn’t have any built-in tools for that purpose. This mel script is going to save us a lot of time.

The Author of the script is Byterunner. Unfortunately, I haven’t found any other information, or links to add to his/her work.

So instead of selecting randomly all the faces in a geometry in Maya, and losing a lot of time, especially if we are working on a high-polygon mesh, we could use this mel script.

Select random faces in Maya (mel script):

What basically does is randomly select a percentage of faces we specify of an object in Maya. Each time we run the script, the faces that will be selected will be random, every time, which is cool.

In order to use it, we have to select an object or more and run the script in Maya from the Script Editor in the proper code language (mel).

Note: The percentage selection of faces is per object, for instance. If we select two or more objects and run the select random faces mel script, the percentage selection will be per object and not for our overall selection objects.

You can find the mel script below:

We have one parament we can change depending on our goal, and that’s the percentage of face selection. Which is the second line of the above script (float $selectPercent = 0.10;).

0 means there will be no face selection at all and 1 means all the faces will be selected. By default, the script is set at 0.10 which means 10% of faces will be selected for the selected object(s) in Maya.

Additionally, it’s a good idea, for ease of access, to put the script on a shelf in Maya to reuse it when you need it.

You may be interested in the below mel scripts in Maya as well:

Let’s try out this mel script in Maya, to see it in action, with a simple polygonal sphere geometry.

Select random faces in Maya:

Select the sphere mesh and open up the Script Editor by going to Windows – General Editors – Script Editor. Navigate to a mel script tab, and paste the above mel script.

In this example, we will set the percentage to 0.35 (approximately 1/3 faces of our object). Highlight the whole mel script and hit ctrl + enter to execute the script.

select random faces in Maya, run the script

As we can see, our select random faces in Maya mel script have selected approximately 1/3 of the faces of our sphere.

Lastly, we can combine this mel script with the technique to add randomness to our geometry in Maya. In that way, we can only add randomness to a percentage of faces in our geometry, and not in the whole mesh.

Popular posts

inspire others:

Picture of Vladi Dan

Vladi Dan

Hey there. I am an experienced 3D Artist - Graphic Designer for over 7 years. Of course, the learning process doesn't really end. I am more than happy to share my personal knowledge with you guys. Let's create and learn some cool stuff together. I hope you join me on this creative trip.

One Response

Leave a Reply

Your email address will not be published. Required fields are marked *

Latest Posts