// EJL_trianglesSuck // 8-21-08 proc EJL_trianglesSuck() { string $sel[] = `ls -sl`; int $selsize = `size($sel)`; int $numtris = 0; int $numtriobjs = 0; string $killList[]; print "\n\n"; if ($selsize == 0) { error "EJL Says: You must select at least one object\n"; } for ($x in $sel) { select -r $x; //select all quads polyCleanupArgList 3 { "0","2","0","1","0","0","0","0","0","1e-005","0","1e-005","0","1e-005","0","-1","0" }; //invert the selection to select all tris and ngons invertSelection; string $triangles[] = `ls -fl -sl`; int $trisize = `size($triangles)`; if ($trisize == 0) { // do nothing for now } else if ($trisize != 0) { // increment counters $numtriobjs = ($numtriobjs + 1); $numtris = ($numtris + $trisize); // add problem geo to the kill list int $z = ($numtriobjs - 1); $killList[$z] = $x; // feedback print "------------------------------------------------------\n"; print ("EJL Says: " + $trisize + " n-gons detected on " + $x + "! They are:\n"); print $triangles; print "\n"; } // toggle to object mode if no n-gons exist if ($numtriobjs == 0) { toggleSelMode; select -r $sel; } else if ($numtriobjs != 0) { select -r $killList; //select all quads polyCleanupArgList 3 { "0","2","0","1","0","0","0","0","0","1e-005","0","1e-005","0","1e-005","0","-1","0" }; //invert the selection to select all tris and ngons invertSelection; // convert selection to verts for easier viewing (must include switchComponent proc listed below) switchComponent 3; // switch to wireframe to show hilighted verts string $focus = `getPanel -withFocus`; modelEditor -e -displayAppearance "wireframe" $focus; modelEditor -e -xray 0 $focus; } } // end for loop // final report if ($numtris > 0) { print "=========================================================\n"; print ("Final Report: " + $numtris + " n-gons, across " + $numtriobjs + " objects.\n"); print "The following models have n-gons:\n\n"; print $killList; print "=========================================================\n\n"; print ("EJL Says: " + $numtris + " n-gons, across " + $numtriobjs + " objects. See script editor for details.\n"); } else { print "\n\nEJL Says: No n-gons detected. Good job!\n"; } } // switchComponent.mel // by Naughty (naughty_genepool@hotmail.com) // // This proc is a combination of Maya's default polygon component switching (keys F9-F12) // and the "Convert Selection To..." functions, but with a much more sophisticated // conversion process that makes it much more useful. In fact, I've remapped my F9-F12 // keys to this function and it makes switching components a much more enjoyable // and time-saving experience. // // The proc takes a single int input which controls what to convert the selection // into: 1=face 2=egde 3=vtx 4=UV 5=vtx/Face // // Usage: // // switchComponent ; // // Usage examples: // // switchComponent 2; // converts current component selection into edges // // and switches to edge mode. // // // goto: // http://www.naughtynathan.supanet.com/mel.htm // for more detailed explanations, pictures and even more MEL scripts... proc int isEdgeOrFace() { int $result = 0; string $sel[]; // check if current selection is faces? $sel = `filterExpand -sm 34`; if (size($sel)) $result=1; else { // well then, is current selection edges? $sel = `filterExpand -sm 32`; if (size($sel)) $result=1; } // if not, must be Vtx or UV so: return $result; } global proc switchComponent(int $component) // 1=face 2=egde 3=vtx 4=UV 5=vtx/Face { string $selection[]; switch ($component) { case 1: // Face $selection = `polyListComponentConversion -ff -fv -fe -fuv -fvf -tf -in`; selectType -pv 0 -pe 0 -pf 1 -puv 0 -pvf 0; break; case 2: // Edge if (!`isEdgeOrFace`) $selection = `polyListComponentConversion -ff -fv -fe -fuv -fvf -te -in`; else $selection = `polyListComponentConversion -ff -fv -fe -fuv -fvf -te`; selectType -pv 0 -pe 1 -pf 0 -puv 0 -pvf 0; break; case 3: // Vertex $selection = `polyListComponentConversion -ff -fv -fe -fuv -fvf -tv`; selectType -pv 1 -pe 0 -pf 0 -puv 0 -pvf 0; break; case 4: // UV $selection = `polyListComponentConversion -ff -fv -fe -fuv -fvf -tuv`; selectType -pv 0 -pe 0 -pf 0 -puv 1 -pvf 0; break; case 5: // Vtx/Face $selection = `polyListComponentConversion -ff -fv -fe -fuv -fvf -tvf`; selectType -pv 0 -pe 0 -pf 0 -puv 0 -pvf 1; break; default: error "Unknown component type."; break; } string $nodes[] = `ls -type transform -sl` ; if ($nodes[0] == "") select -r $selection; setSelectMode components Components; } EJL_trianglesSuck;