// EJL Uber Snap Tool v1.2 // By Eric Lyman 3-26-07 // If you like this script, drop a line at mezza550@gmail.com // website: www.eric3d.com // note: 12-11-08, make condition where if obj alredy has shader on faces, turns wires pink instead of using shader, else use shader. global proc EJL_UberSnapTool() { if (!`objExists "sucko"`) { toggleSelMode; toggleSelMode; selectMode -object; } string $ejl[] = `ls -sl`; if (!`objExists "sucko"`) { // error checks... int $sizecheck = `size($ejl)`; if ($sizecheck != 1) { error "EJL Says: Only works with one object selected.\n"; } string $selected_Shape_Node[] = `listRelatives -c $ejl[0]`; if (`nodeType $selected_Shape_Node[0]` != "mesh") { error "EJL says: Sorry, only works on polygons.\n"; } } global string $pm; int $ejlsize = `size($ejl)`; global string $previousMaterial[]; if ($ejlsize == 1 && !`objExists "sucko"`) { // record previous material string $shape[] = `listRelatives -s $ejl[0]`; $previousMaterial = `listConnections -s 0 -d 1 ($shape[0] + ".instObjGroups[0]")`; // duplication process //string $tmp[]; string $tmp[] = `duplicate $ejl[0]`; rename $tmp[0] sucko; string $blah = "sucko"; makeLive sucko; setAttr "sucko.visibility" 0; // remove from hiarchy (unparent) // find location in hiarchy string $nameParent = firstParentOf($blah); if ($nameParent == "") { // do nothing, as it was not grouped under anything } else { select -r sucko; parent -a -w; } // create shader for object being manipulated if ( !`objExists "EJL_ubersnaptool_shader"`) { // make shader and assign string $shader = `shadingNode -asShader -n EJL_ubersnaptool_shader lambert` ; string $sg = `sets -renderable true -noSurfaceShader true -empty -name EJL_ubersnaptool_shaderSG`; connectAttr -f ($shader + ".outColor") ($sg + ".surfaceShader"); setAttr ($shader + ".color") -type double3 0.721 0.716227 0.607803 ; // assign shader sets -e -forceElement $sg $ejl[0]; // turn edges pink /* displayColor -active "lead" 20; displayColor -dormant "polyEdge" 20; select -r $ejl; */ } else { // just assign shader select -r $ejl[0]; sets -e -forceElement EJL_ubersnaptool_shaderSG; /* displayColor -active "lead" 20; displayColor -dormant "polyEdge" 20; select -r $ejl; */ } // feedback print "EJL says: Uber Snap Tool is ON.\n"; // make duplicate variable for else statement, for some reason it has to be this way to work? $pm = $ejl[0]; } else { if (`objExists "sucko"`) { // reassign old shader // turn edges back normal /* displayColor -active "lead" 19; displayColor -dormant "polyEdge" 22; */ //select -r $ejl; sets -e -forceElement $previousMaterial $ejl[0]; // sets -edit -forceElement $previousMaterial[0] $pm; // kill live geo makeLive -none; delete sucko; // feedback print "EJL says: Uber Snap Tool is OFF.\n"; } else { // error feedback error "EJL Says you must have at least one object selected!"; } } } // What does this script do? // // The purpose for this tool is to provide modelers with an end all component snap tool. // Maya can snap to the grid, to curves or points fairly easily, but to do all three requires a bit // of time on the artists part. With this tool you can easily jump in and out of a 'snap to everything' mode. // // How does it work? // // Quite simply this script will duplicate a selected polygon object, make the duplicate live, and then // hide the live surface. Now you can freely move the components (verts, edges, faces) with the translate // tool and not have to worry about losing volume on your model. This is ideal for re-doing topology. // // How to use this script: // // Copy the MEL file to your scripts directory (for example, UserDirectory/maya/7.0/scripts/ // In the script editor or command line type the following: // // source EJL_uberSnapTool.mel; EJL_uberSnapTool; // // This line can also be entered as a hotkey, put on to a marking menu, or a shelf button. // The script works as a toggle, so it's highly recommended that you do this. // // // // Known Bugs: // - Only works well with polygon objects at the moment. // - Does not work with any object that has facet level shader assignments. // - Works on softmod handle, need to make it only work on geometry. // - Does not work when starting in component mode // // Suggestions // - Make live geometry "nameofgeo_uber", placed inside group.Upon exit, delete group. //