Thursday, October 4, 2018

Script to select random faces on your object (MAYA)



Select your object, Copy this into your mel  script into the mel box and hit enter it will take a moment and select random faces!



 string $faces[] = {};
  float $selectPercent = 0.10;
  for($each in `ls -sl`)
  {
  int $nFaces[] = `polyEvaluate -f $each`;
  int $sFaces = $nFaces[0] * $selectPercent;
  for($i=0;$i<$sFaces;$i++)
  {
  string $rFace = $each + ".f[" + int(`rand 0 $nFaces[0]`) + "]";
  while(stringArrayContains($rFace, $faces) == 1)
  {
  $rFace = $each + ".f[" + int(`rand 0 $nFaces[0]`) + "]";
  }
  $faces[size($faces)] = $rFace;
  }
  }
  select -r $faces;



Change $selectPercent = 0.10 to whatever percentage you’d like. It’s currently at 10%. This works across multiple objects and will select a percentage of faces per object, not a percentage of the total faces.


This was graciously created by Byterunner

https://forums.cgsociety.org/t/script-to-select-random-faces-on-object/1384634/4



Thanks buddy!