Last active
August 29, 2015 14:27
create camera from viewport
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.cmds as mc | |
#find current cam | |
currentPan = None | |
currentPan = mc.getPanel(wf=True) | |
#check viewport is selected | |
exists = mc.modelPanel(currentPan, ex=True) | |
def createCam(): | |
if exists: | |
#find current cam | |
cam = mc.modelPanel(currentPan, q=True, camera=True) | |
else: | |
mc.confirmDialog(title='Warning', message='Please select viewport', button='ok') | |
return | |
newCam = mc.duplicate(cam, name= 'cam0#') | |
#show resolution gate | |
mc.camera( newCam, e=True, dr=True ) | |
mc.setAttr(str(newCam[0])+'.visibility',1, e=True) | |
#open in another window | |
window = mc.window(widthHeight=(800, 800)) | |
mc.paneLayout() | |
pan = mc.modelPanel() | |
# display smooth shaded, no nurb curves | |
mc.modelEditor(pan, e=True, da="smoothShaded", nc=False, gr=False) | |
mc.lookThru(pan, newCam) | |
mc.showWindow( window ) | |
createCam() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment