The cmds.playblast works well when run from Maya in standalone, but I’m having trouble specifying which camera to playblast through.
From the GUI, I typically use..
import maya.cmds
maya.cmds.lookThru("myCamera")
maya.cmds.playblast()
But in standalone, this gives me an error.
>>> maya.cmds.lookThru("persp")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: There is no active view.
Are there any other methods of specifying a camera for playblast?
To clarify what I mean by “standalone”
$ mayapy
>>> import maya.standalone
>>> maya.standalone.initialize()
>>> import maya.cmds
>>> maya.cmds.lookThru("modelPanel1", "top")
>>> maya.cmds.setFocus("modelPanel1")
>>> maya.cmds.playblast()
This works in GUI mode, but not in standalone i.e. via command-line, so long as the panel itself is visible in Maya.
cams = cmds.ls(type='camera')
for cam in cams:
cmds.setAttr(cam + '.rnd', 0)
cams = mc.ls(type='camera')
for cam in cams:
cmds.setAttr(cam + '.rnd', 0)
cmds.setAttr('myCamShape.rnd', 1)
import contextlib
@contextlib.contextmanager
def solo_renderable(solo_cam):
# Disable all cameras as renderable
# and store the original states
cams = cmds.ls(type='camera')
states = {}
for cam in cams:
states[cam] = mc.getAttr(cam + '.rnd')
cmds.setAttr(cam + '.rnd', 0)
# Change the solo cam to renderable
cmds.setAttr(solo_cam + '.rnd', 1)
try:
yield
finally:
# Revert to original state
for cam, state in states.items():
cmds.setAttr(cam + '.rnd', state)
with solo_cam('myCamShape'):
cmds.playblast()
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/19702d7f-db58-4cdf-ab1c-060284fa0da4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.