///////////////////////////////////////////////////// // // // // // created by: Mike Paixao // // // // // // 1: enter your file texture name // // 2: and then your uv set name to connect // // 3: select your objects you want to run this on // // 4: hit connect // // // ///////////////////////////////////////////////////// global proc mUvTextureConnect(string $texture, string $UvSet) { string $uvChooser; pickWalk -d down; $sel = `ls -sl -s`; if(`size $sel` == 0) error "no objects were selected"; $textName = `textField -q -tx $texture`; $UvName = `textField -q -tx $UvSet`; $allTextures = `listConnections $textName`; $p2d = `ls -type "place2dTexture" $allTextures`; $allChoosers = `listConnections $p2d`; $uvChoo = `ls -type "uvChooser" $allChoosers`; if (`size $uvChoo` == 0) { $uvChooser = `shadingNode -asUtility uvChooser`; connectAttr -f ($uvChooser + ".outUv") ($p2d[0] + ".uvCoord"); connectAttr -f ($uvChooser + ".outVertexCameraOne") ($p2d[0] + ".vertexCameraOne"); connectAttr -f ($uvChooser + ".outVertexUvThree") ($p2d[0] + ".vertexUvThree"); connectAttr -f ($uvChooser + ".outVertexUvTwo") ($p2d[0] + ".vertexUvTwo"); connectAttr -f ($uvChooser + ".outVertexUvOne") ($p2d[0] + ".vertexUvOne"); } else $uvChooser = $uvChoo[0]; int $count = 0; string $uvSetCheck = "junk to get it going"; while(`size $uvSetCheck` > 0) { $uvSetCheck = ""; for ($obj in $sel) { $uvSetCheck = `getAttr ($obj + ".uvSet[" + $count +"].uvSetName")`; if($uvSetCheck == $UvName) { int $countObj = 0; string $getChooserNumber = "get it started again..."; while(`size $getChooserNumber` != 0) { $getChooserNumber = `getAttr ($uvChooser+".uvSets["+ $countObj +"]")`; if (`size $getChooserNumber` == 0) connectAttr -f ($obj + ".uvSet[" + $count + "].uvSetName") ($uvChooser+".uvSets["+ $countObj +"]"); $countObj += 1; } } } $count +=1; } } { if (`window -exists mUvTexture`) deleteUI mUvTexture; string $window = `window -title "UV map to Texture" mUvTexture`; columnLayout -adjustableColumn true; $texture = `textField -text "enter texture name here"`; $UvSet = `textField -text "enter UV map name here"`; button -label "Connect" -command ("mUvTextureConnect(\"" + $texture + "\", \"" + $UvSet +"\")"); setParent ..; window -edit -widthHeight 260 105 $window; showWindow $window; }