Skip to content
Advertisement

When the viewport isolates a object, ogsRender() still renders all objects

the viewport like this: 3 objects, 1 selected(the green one).

enter image description here

my code:

import maya.cmds as cmds
# isolate selected object. (Ctrl+1)
cmds.isolateSelect("modelPanel4",state=True)
cmds.isolateSelect("modelPanel4",aso=True)
# snapshot.
cmds.ogsRender(h=512, w=512, cv=True, ems=True)

When I execute them one by one, the result is as expected. only the “green one” is in the screenshot.

enter image description here

When I execute them together, isolate becomes invalid. all 3 objects are in the screenshot.

enter image description here

Why??

Advertisement

Answer

This is because the Viewport is locked when the script is running. need to insert refresh command before the screenshot.

cmds.refresh(cv=True, f=True)
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement