Hey all,
We’ve got a “nag” in Maya 2015 where you need to sit and look at “Viewport 2.0 processing…” for at least a minute when you execute cmds.playblast
and when using VP2.0/OpenGL.
Here’s the code which is part of an application which grabs the active viewport and saves it down to a small PNG image:
import maya.cmds as cmds
active_panel = cmds.playblast( activeEditor=True )
current_frame = cmds.currentTime(q=True)
cmds.modelEditor(active_panel, edit=True, hud=False) # hide HUD
cmds.playblast(frame=[current_frame], percent=100, offScreen=True, width=300, height=169, widthHeight=[300,169], format='image', compression='png', completeFilename='c:/users/fredrik/desktop/playblast.png', viewer=False)
cmds.modelEditor(active_panel, edit=True, hud=True) # show HUD
I really don’t understand why and when the processing bit is required by Maya. If you run this code a second time, the processing nag isn’t there anymore and the PNG is generated within a couple of seconds. However, artists in my studio say that it’s not only the first time you do the playblast that the processing happens. So perhaps if you make changes to the scene or moves the camera around, the processing happens again. Not really sure.
If I quickly change the viewport into the Legacy one (via cmds.modelEditor), the PNG is generated within seconds at all times. So this could be one approach to avoid the minute-long wait to screenshot the active viewport in Maya 2015.
Can anyone shed some light on what’s going on, and if there’s a way to avoid the processing wait?
Perhaps there’s a more clever way to get a quick screenshot of the viewport? – For example, does anyone know how the snapshot feature work in Maya’s render view and if it could be accessible through Python/MEL?
Regards,
Fredrik
--
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/CAD%3DwhWOjVv7j_zkMbNuHAXQTZ5B2AVj%3Dx6XYpyNM2tP65Q_OxA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
import maya.OpenMaya as om
import maya.OpenMayaUI as omui
view = omui.M3dView.active3dView()
image = om.MImage()
view.readColorBuffer(image, True)
image.resize(300, 169)
image.writeToFile('/path/goes/here', 'png')