the viewport like this: 3 objects, 1 selected(the green one).
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.
When I execute them together, isolate becomes invalid. all 3 objects are in the screenshot.
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)