Maya Zoom/Pan Tools Script

Here goes another tool for productivity. No more scrolling in attr editor for pan/zoom 🙂

How to:
1. copy script to script editor in Python tab, select all text and then MM drag it to your shelf.
2. select a camera
3. hit the little icon with a looking glass over the viewport
4. press in your shelf button to launch
5. have fun

 

import maya.cmds as cmds

cam=cmds.ls(sl=True)
if len(cam)<1:
    cmds.confirmDialog(message="select a camera")
else:
    camShape=cmds.listRelatives(cam)

def reset():
    cmds.panZoom(camShape,abs=True,z=1)
    cmds.panZoom(camShape,abs=True,l=0)
    cmds.panZoom(camShape,abs=True,d=0)
    cmds.floatSliderGrp(valZ, edit=True, value=1)
    cmds.floatSliderGrp(valX, edit=True, value=0)
    cmds.floatSliderGrp(valY, edit=True, value=0)

def paniZoom():   
    zoomRate=cmds.floatSliderGrp(valZ, query=True, value=True)
    cmds.panZoom(camShape,abs=True,z=zoomRate)

    widthRate=cmds.floatSliderGrp(valX, query=True, value=True)
    cmds.panZoom(camShape,abs=True,l=widthRate)

    depthRate=cmds.floatSliderGrp(valY, query=True, value=True)
    cmds.panZoom(camShape,abs=True,d=depthRate)

windowZ=cmds.window(title="Zoom/pan",w=350,h=250)
cmds.columnLayout(w=150,adj=True)
valZ=cmds.floatSliderGrp(label="Zoom", field=True,dc="paniZoom()",value=1,min=-0.001,max=1,pre=3)
valY=cmds.floatSliderGrp(label="Vertical Pan", field=True,dc="paniZoom()",value=0,min=-1,max=1,pre=3)
valX=cmds.floatSliderGrp(label="Horizontal Pan", field=True,dc="paniZoom()",value=0,min=-1,max=1,pre=3)

resetButton=cmds.button(label="reset", c="reset()")
cmds.showWindow(windowZ)
cmds.panZoom(camShape,abs=True,z=10)

reset()
Advertisements

2 thoughts on “Maya Zoom/Pan Tools Script

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s