Tech Tip Tuesday: Framing

There’s a lot of little bits of code that I have assigned to hotkeys and marking menus that aren’t really substantial enough to be stand-alone scripts. If I can, I’m going to try to post an example each week, as a way to keep myself motivated to update. So here’s the first one, just a variation on framing, which you would normally have assigned to “f”. The only difference is it scales your graph editor to the current timeline, and centers around the current frame:


fitPanel -selected;
if (!size(`keyframe -q -selected`)){
    $start = `playbackOptions -q -minTime`;
    $end = `playbackOptions -q -maxTime`;

    animCurveEditor -e -lookAt "selected" "graphEditor1GraphEd";
    animView -startTime ($start-1) -endTime ($end+1)  "graphEditor1GraphEd";
    animCurveEditor -e -lookAt "currentTime" "graphEditor1GraphEd";


import maya.cmds as mc
import maya.mel as mm

mm.eval('fitPanel -selected')
if not mc.keyframe(query=True, selected=True):
    start = mc.playbackOptions(query=True, minTime=True)
    end = mc.playbackOptions(query=True, maxTime=True)

    mc.animCurveEditor('graphEditor1GraphEd', edit=True, lookAt='selected')
    mc.animView('graphEditor1GraphEd', startTime=start-1, endTime=end+1)
    mc.animCurveEditor('graphEditor1GraphEd', edit=True, lookAt='currentTime')

The best thing about Maya is that you don’t have to take it at face value, if you don’t mind getting your hands a little dirty you can customize pretty much everything to how you want to work.

Share Button
This entry was posted in Maya, MEL, Python, Tech Tip Tuesday, Tools. Bookmark the permalink.

2 Responses to Tech Tip Tuesday: Framing

  1. Aristides says:

    Hello Morgan Loomis

    I know this has been very old post, but I’m just wondering if you know how to make a script that does this:
    frame all, frame playback range and zoom vertically to fit the current curve.

    I cannot find anything in internet.

    Any help would be appreciated. Thanks for the Tip

  2. Hey thanks for laying out the idea and testing this for me, the tool is ready to go:

Leave a Reply

Your email address will not be published. Required fields are marked *