Unfortunately it's not really obvious from any documentation.
It seems that when Maya is running in standalone mode it takes a
'renderable' camera to playblast.
For example try:
cams = cmds.ls(type='camera')
for cam in cams:
cmds.setAttr(cam + '.rnd', 0)
And then playblasting in standalone. You'll get a fatal error.
The trick is to only keep your preferred camera as a renderable camera.
cams = mc.ls(type='camera')
for cam in cams:
cmds.setAttr(cam + '.rnd', 0)
cmds.setAttr('myCamShape.rnd', 1)
This will ensure your standalone Maya will capture that camera.
In standalone you might not be saving your scene (batch playblast?), but if
you don't want to mess to much with the scene state you could wrap your
playblast in a context. Like so:
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()
On Thursday, August 27, 2015 at 9:40:53 AM UTC+2, Marcus Ottosson wrote:
>
> 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?
>
> --
> *Marcus Ottosson*
> [email protected] <javascript:>
>
--
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 [email protected].
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.