Maya Scripts

  • In my spare time I sometimes write scripts to help me animate. Feel free to use them yourself. You can contact me about any bugs or issues.
  • If any of these scripts help you, I'd love to know about it!
  • Please send me a message or consider a small donation through Gumroad. Thanks!

pn_createProxyGeo.py
  • With this script you can generate low-res cubes on a selection of rig controls, which will follow the animation.
    This way, you can hide your rig, speed up the viewport and get a better sense of the timing of your animation.


  • Get it on Gumroad: createProxyGeo

pn_selectCurves.py
  • With this script you can quickly select all rig controls. On one or more specific rigs, in the whole scene, or by naming scheme.

  • Get it on Gumroad: selectCurves

pn_makePlayblast.mel
  • I use this script to make quick playblasts. Put it on a marking menu to start playblasting at a flick of your cursor.

  • Script language: MEL
                
//pn_makePlayblast.mel
//v 1.0
proc makePlayblast()
{
    global string $gPlayBackSlider;
    float $timeRange[] = {};
    $timeRange[0] = `playbackOptions -q -min`;
    $timeRange[1] = `playbackOptions -q -max`;

    if (`timeControl -q -rangeVisible $gPlayBackSlider`)
        $timeRange = `timeControl -q -rangeArray $gPlayBackSlider`;

    playblast  -format avi -sound `ls -type audio` -startTime $timeRange[0] -endTime $timeRange[1]
-sequenceTime 0 -clearCache 1 -viewer 1 -showOrnaments 0 -fp 4 -percent 50 -compression "none"
-quality 100 -widthHeight 1920 1080; } makePlayblast();

pn_toggleSound.mel
  • I use this script to toggle the sound of my shot on or off. Can be useful when the sound gets on your nerves...

  • Script language: MEL
                
//pn_toggleSound.mel
//v 1.0
proc toggleSound()
{
    string $smurfSound[] = `ls -type audio`;
    if (getAttr ($smurfSound[0]+".mute") == true)
        setAttr ($smurfSound[0]+".mute") 0;
    else
        setAttr ($smurfSound[0]+".mute") 1;

}
toggleSound();
                
              

pn_refEditor.mel
  • A very simple one, it just opens the ref editor so you can load/unload references more easily. Put it on a shelf button or a shortcut.

  • Script language: MEL
                
//pn_refEditor.mel
//v 1.0
ReferenceEditor;
tearOffRestorePanel "Reference Editor" referenceEditor true;
                
              

pn_showSelectedTypeGraph.mel
  • This one filters the selected channels in the graph editor. This way you only see the animcurves you're interested in.

  • Script language: MEL
                
//pn_showSelectedTypeGraph.mel
//v 1.0
proc showSelectedTypeGraph()
{
    string $myPanel = `getPanel -withLabel "Graph Editor"`;
    
    if (`panel -q -label $myPanel` == "Graph Editor")
        filterUIFilterSelection ($myPanel+"OutlineEd") "menu38|FilterUISaveFilterMenuItem";      
}
showSelectedTypeGraph();
                
              

pn_deleteBetweenFrames.py
  • Using this script deletes all keyframes that are not on whole frames.

  • Script language: Python
                
"""
__title__ = "pn_deleteBetweenFrames.py"
__author__ = "Pauwel Nomes"
__copyright__ = "Copyright (C) 2022 Pauwel Nomes"
__version__ = "1.0"

This script deletes any non-whole keyframes after you scaled and snapped.
It works on either the whole timeline or you can have a range selected.
"""
import maya.cmds as cmds
import maya.mel as mel

def deleteBetweenFrames():

    sel = cmds.ls(sl = True)
    number_of_frames = 0

    gPlayBackSlider = mel.eval('$tempVar = $gPlayBackSlider')
    timeRange = {}
    timeRange[0] = cmds.playbackOptions(q = True, min = True)
    timeRange[1] = cmds.playbackOptions(q = True, max = True)

    if cmds.timeControl(gPlayBackSlider, q = True, rangeVisible = True):
             timeRange = cmds.timeControl(gPlayBackSlider, q = True, rangeArray = True)

    for object in sel:
        all_keyframes = cmds.keyframe(object, q = True, timeChange = True, time = (timeRange[0],timeRange[1]))
        for frame in all_keyframes:
            if frame % 1 != 0:
                cmds.cutKey(object, clear = True, time = (frame,frame))
                number_of_frames += 1
    print("{0} bad frames deleted!".format(number_of_frames))

deleteBetweenFrames()