Skip to content

Instantly share code, notes, and snippets.

@AnsleyCG
AnsleyCG / nDotEyeRemap.mel
Created August 1, 2017 16:59
Facing ratio shader netwrok remapped to two ramp textures
//Create a Facing Ratio Shading Network and remap to two Ramp Textures
shadingNode -asUtility samplerInfo -n "mySamplerInfo";
shadingNode -asUtility reverse -n "myReverse";
connectAttr -f mySamplerInfo.facingRatio myReverse.inputX;
connectAttr -f mySamplerInfo.facingRatio myReverse.inputY;
connectAttr -f mySamplerInfo.facingRatio myReverse.inputZ;
shadingNode -asUtility rgbToHsv -n "myRgbToHsv";
connectAttr -f myReverse.output myRgbToHsv.inRgb;
shadingNode -asTexture ramp -n "myRamp_01";
shadingNode -asTexture ramp -n "myRamp_02";
@AnsleyCG
AnsleyCG / riggingCleanupCheck.py
Last active May 15, 2017 19:01
WIP - Cleanup
import maya.cmds as cmds
##Warning labels
warningStars = "***"
warningText = "There is more than one child"
translateWarning = "*** Translate != 0 ***"
rotateWarning = "*** Rotate != 0 ***"
scaleWarning = "*** Scale != 0 ***"
emptyWarning = "I'm empty inside :("
shapeNameWarning = "**The transform and shape do not share a name**"
@AnsleyCG
AnsleyCG / selectAndAssign.py
Last active May 10, 2017 21:56
Select an object and run to get a list of shaders assigned to that object, select a new object and press "Assign" to assign the listed shader to the new object
##Select an object and run to get a list of Shaders assigned to that object
##Select a new object and press "Assign" to assign the listed shader to the new object
##Uncheck "Close after assignment" to assign shaders to objects one after another
import maya.cmds as cmds
def getShadersFromSelected():
getShaders = []
cmds.hyperShade(shaderNetworksSelectMaterialNodes = True)
assignedToObject = cmds.ls(sl = True)
@AnsleyCG
AnsleyCG / sinPower.py
Created May 9, 2017 00:04
Use the rotation of an object as an on off switch
##Use the rotation of an object as an on off switch
from math import sin
x = 0
while x < 360:
##
a = ( ( sin( ( ( (x+270)/360 )*4 )*1.57 )/2 )+0.5 )
## This is the important part ^^^^^
a = round(a, 3)
print (x,a)
@AnsleyCG
AnsleyCG / normalizeValue.py
Last active May 8, 2017 23:02
Normalize a given value within a given range (0-1)
## random is for testing only
from random import uniform
## x represents any given value within a desired range
## m represents the minimum value within the range
## ma is the maximum
## in this example, a random number is chosen within the range of 10 to 235
## the tool will convert the random number to a value between 0 and 1
x = round(uniform(10, 235), 2)
m = 10
@AnsleyCG
AnsleyCG / uvQuickEditorMenu.py
Created May 8, 2017 21:49
A Quick tool menu for Maya's UV Editor
import maya.cmds as mc
import maya.mel
def uvEditor():
uvEditor = "UV Editor Tools"
if maya.cmds.window(uvEditor,ex=True):
maya.cmds.deleteUI(uvEditor)
mc.window(uvEditor, title = uvEditor, widthHeight = (300,300))
mc.columnLayout()
@AnsleyCG
AnsleyCG / tearOffCamera.mel
Created May 5, 2017 19:57
MAYA - Tear off a selected camera and set all objects display to OFF except POLYGONS
//Tear off a selected camera and set all objects display to OFF except POLYGONS
//Select a Camera in the Outliner/Hypergraph
//Hover mouse over current view (eg., Persp) and tap CTRL/CMD
//Click button to run command
$camera = `ls -sl`;
$panel = `getPanel -wf`;
$activeCam = `modelPanel -q -cam $panel`;
$tearCam = $camera[0];
@AnsleyCG
AnsleyCG / vertSnapCreation2.mel
Last active December 13, 2016 23:01
SpikeBall Script
polyCube -w 10 -h 10 -d 10 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1 -n "ball";
polySmooth -dv 2;
for( $i=0; $i<98; ++$i ) {
float $randRad = rand(1.0, 2.5);
vector $vertPos = `pointPosition ball.vtx[$i]` ;
float $vertX = $vertPos.x;
float $vertY = $vertPos.y;
float $vertZ = $vertPos.z;
float $randMV = rand(0.1, 0.5);
@AnsleyCG
AnsleyCG / DepthShaderTool.mel
Created November 10, 2016 23:58
Create a Depth Shader with controls based off distances relative to the camera.
//DepthShaderTool
//Move the nearPoint locator to the closest point in the renderable camera's field of view.
//Move the farPoint locator to the farthest point in the renderable camera's field of view.
//Assign the shader to all objects in the scene (optionally create a new render layer and shader override).
//Adjust the position of the near and farPoint to adjust the values of white and black in the render.
$cameras = `ls -sl`;
if ( size($cameras)==0 ) {
print "**Please select a camera**";
@AnsleyCG
AnsleyCG / Quick Light
Last active October 1, 2016 00:09
Create a Physical Light Node in Maya, connected to the Colour and Intensity of the Light Shape, with the click of a button
//Create an Area Light
CreateAreaLight;
rename "testAreaLight";
setAttr "testAreaLight.scaleZ" 10;
setAttr "testAreaLight.scaleX" 10;
setAttr "testAreaLight.scaleY" 10;
setAttr "testAreaLightShape.areaLight" 1;
setAttr "testAreaLightShape.decayRate" 1;
//create and connect a PhysLight Node