the viewport like this: 3 objects, 1 selected(the green one).
my code:
JavaScript
x
7
1
import maya.cmds as cmds
2
# isolate selected object. (Ctrl+1)
3
cmds.isolateSelect("modelPanel4",state=True)
4
cmds.isolateSelect("modelPanel4",aso=True)
5
# snapshot.
6
cmds.ogsRender(h=512, w=512, cv=True, ems=True)
7
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.
JavaScript
1
2
1
cmds.refresh(cv=True, f=True)
2