pymel > Get current viewport camera? OOP


#1

Is it possible to return current viewport camera as an object with pymel?
I got this far and I am lost

from pymel.core import *
pan = getPanel( withFocus=True )
If I just return a camera as an unicode string I can't do things like this right? 
cam.setFocalLength(24)
Any help would be very much appreciated!

#2

You can convert the string to object with PyNode.

cam = pm.PyNode( pm.modelPanel(pm.getPanel(withFocus=True), q=True, cam=True ) )


#3

Thank you so much for your help myara!
I had no idea about the pynode and obviously I need to study more.
Anyway it’s great to be able to convert it.
Thanks again for taking the time to answer!

Awesome! This worked beautifully :smiley:

from pymel.core import *
  cam = PyNode( modelPanel(getPanel(withFocus=True), q=True, cam=True ) )
  cam.setFocalLength(24)