Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.7 kB
9
Indexable
import maya.mel as mel
import pymel.core as pm

def setOverscan(*args):
  originalWidth = float(args[0])
  originalHeight = float(args[1])
  newWidth = float(args[2])
  newHeight = float(args[3])

  camera = pm.ls(sl=True)[0]
  originalApertureWidth = camera.horizontalFilmAperture.get()
  originalApertureHeight = camera.verticalFilmAperture.get()

  overscanWidth = newWidth / originalWidth
  overscanHeight = newHeight / originalHeight
  newApertureWidth = originalApertureWidth * overscanWidth
  newApertureHeight = originalApertureHeight * overscanHeight
  
  #print originalWidth, originalHeight, newWidth, newHeight
  camera.horizontalFilmAperture.set(newApertureWidth)
  camera.verticalFilmAperture.set(newApertureHeight)
  
  pm.setAttr("defaultResolution.width", newWidth)
  pm.setAttr("defaultResolution.height", newHeight)

  pm.setAttr("vraySettings.width", newWidth)
  pm.setAttr("vraySettings.height", newHeight)
    

win = pm.window(title = 'Set camera overscan', height = 100, width = 300)
layout = pm.columnLayout(rowSpacing=10, adjustableColumn=True)
label = pm.text(label='Original resolution', bgc=(0.3, 0.3, 0.1))
originalWidth = pm.textField(text = pm.getAttr("defaultResolution.width"))
originalHeight = pm.textField(text = pm.getAttr("defaultResolution.height"))
label = pm.text(label='Overscanned resolution', bgc=(0.2, 0.4, 0.4))
newWidth = pm.textField(text = pm.getAttr("defaultResolution.width"))
newHeight = pm.textField(text = pm.getAttr("defaultResolution.height"))
btn = pm.button(label = 'Set overscan', command = lambda *args: setOverscan(originalWidth.getFileName(), originalHeight.getFileName(), eval(newWidth.getFileName()), eval(newHeight.getFileName())))

win.show()