Skip to content

Instantly share code, notes, and snippets.

import maya.cmds as mc
import maya.mel
def renameWindow():
renameWin = "RenameRenderLayerWindow"
if maya.cmds.window(renameWin,ex=True):
maya.cmds.deleteUI(renameWin)
mc.window(renameWin, title = renameWin, widthHeight = (300,400))
mc.columnLayout()
@AnsleyCG
AnsleyCG / testRenderTargetCreator.mel
Last active May 4, 2016 02:10
Create render targets in Maya to minimize rerendering large background layers for test renders.
//Render Targets
shadingNode -asRendering renderTarget -name BG_Target;
shadingNode -asRendering renderTarget -name FG_Target;
shadingNode -asRendering renderTarget -name BG_FG_Target;
shadingNode -asRendering renderTarget -name COMP_Target;
//Layered Textures
shadingNode -asTexture layeredTexture -name BG_FG_Texture;
shadingNode -asTexture layeredTexture -name COMP_Texture;
@AnsleyCG
AnsleyCG / emailRender.ps1
Last active May 4, 2016 02:10
Create an email and send after a render is completed
$EmailFrom = “from@gmail.com”
$EmailTo = “to@gmail.com”
$Subject = “Your Render Is Ready!”
$Body = “Check the Image Folder because your Render is Done!”
$SMTPServer = “smtp.gmail.com”
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“user”, “pass”);
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
@AnsleyCG
AnsleyCG / DOF_Blur
Last active May 4, 2016 02:09
Depth of Field in After Effects with Gausian blur
f = thisComp.layer("Depth Of Field").effect("Focal Point")("Slider")
z = transform.position[2]
m = thisComp.layer("Depth Of Field").effect("Lowest Z-depth")("Layer").transform.position[2]
r = (thisComp.layer("Depth Of Field").effect("Highest Z-depth")("Layer").transform.position[2]) - (thisComp.layer("Depth Of Field").effect("Lowest Z-depth")("Layer").transform.position[2])
n = ((z - m)/r)
d = (f - n)
if (d < 0) d = (d *(-1))
d * Math.pow(thisComp.layer("Depth Of Field").effect("Mutliplier")("Slider"),thisComp.layer("Depth Of Field").effect("Falloff")("Slider"))
@AnsleyCG
AnsleyCG / DOF_Layer
Created May 3, 2016 23:37
Select Layer for DOF_Blur Tool
a = Math.round(thisComp.layer("DOF_Layer").effect("Chapter")("Slider").value)
b = Math.round(thisComp.layer("DOF_Layer").effect("Scene")("Slider").value)
c = comp("CH" + a + "_SC" + b);
c.layer(thisLayer.name).effect("Gaussian Blur")("Blurriness")
@AnsleyCG
AnsleyCG / matToMIA_X.mel
Last active May 17, 2016 00:11
Convert material to MIA_Material_X
$suffix="_MIA";
$shaderName=`ls -sl`;
$newName=($shaderName[0] + $suffix);
$sgName=($shaderName[0] + "_SG");
disconnectAttr ($shaderName[0] + ".outColor") ($sgName + ".surfaceShader");
shadingNode -asShader -name "MIA_MAT_X" "mia_material_x";
if (`connectionInfo -isDestination ($shaderName[0] + ".color")`) {
@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
@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 / 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 / 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];