global proc RampRotate() { string $objs[] = `ls -sl`; string $masterRamp = `createNode ramp -n "masterRamp"`; setAttr ( $masterRamp + ".colorEntryList[0].color" ) -type double3 0 0 0; setAttr ( $masterRamp + ".colorEntryList[1].color" ) -type double3 1 0 0; setAttr ( $masterRamp + ".colorEntryList[1].position" ) 1; float $bbox[] = `exactWorldBoundingBox $objs`; float $width = $bbox[0] - $bbox[3]; float $depth = $bbox[2] - $bbox[5]; print ( "Width: " + $width + " Depth: " + $depth + "\n" ); float $XtoU = 1.0 / $width; float $ZtoV = 1.0 / $depth; for( $obj in $objs ) { string $ramp = `createNode ramp`; connectAttr -f ( $masterRamp + ".colorEntryList[0]" ) ( $ramp + ".colorEntryList[0]" ); connectAttr -f ( $masterRamp + ".colorEntryList[1]" ) ( $ramp + ".colorEntryList[1]" ); connectAttr -f ( $masterRamp + ".type" ) ( $ramp + ".type" ); connectAttr -f ( $masterRamp + ".interpolation " ) ( $ramp + ".interpolation " ); string $uctx = `createNode unitConversion`; connectAttr ( $obj + ".boundingBoxCenterX" ) ( $uctx + ".input" ); connectAttr ( $uctx + ".output" ) ( $ramp + ".uCoord" ); setAttr ( $uctx + ".conversionFactor" ) $XtoU; string $uctz = `createNode unitConversion`; connectAttr ( $obj + ".boundingBoxCenterZ" ) ( $uctz + ".input" ); connectAttr ( $uctz + ".output" ) ( $ramp + ".vCoord" ); setAttr ( $uctz + ".conversionFactor" ) $ZtoV; string $uc = `createNode unitConversion`; connectAttr ( $ramp + ".outColorR" ) ( $uc + ".input" ); connectAttr ( $uc + ".output" ) ( $obj + ".rotateZ" ); // ROTATION AXIS setAttr ( $uc + ".conversionFactor" ) 3.14159265; } }