Catch the end of viewport 2.0 processing process

250 views
Skip to first unread message

likage

unread,
May 30, 2017, 4:30:59 PM5/30/17
to Python Programming for Autodesk Maya
I am trying to get the end if processing time taken when switching to viewport2.0.

In my code, I start off by doing custom settings in renderer then switching to viewport 2.0

However when switch, it took a while for Maya to process, like 3 to 5 seconds before I see the message 'viewport 2.0 is processing'..

Is there any way that I can catch once the processing is done before I execute my next function?

Michael Boon

unread,
May 30, 2017, 5:33:41 PM5/30/17
to Python Programming for Autodesk Maya
Sorry, I don't know, but here are some ideas.
Perhaps use MEventMessage.addEventCallback('idle', fn). I'm not sure when it would fire but it's likely to fire at the same time as a print statement makes it to the Script Editor.
You could look at MRenderer.addNotification with kBeginRenderSemantic.
Worst case, you could subclass MRenderOverride.

likage

unread,
May 30, 2017, 5:56:09 PM5/30/17
to Python Programming for Autodesk Maya
I should have posted my code, here goes:

def set_vp2_settings():
    cmds
.setAttr('hardwareRenderingGlobals.vertexAnimationCache', 2)
    cmds
.setAttr('hardwareRenderingGlobals.hwInstancing', 1)
    cmds
.setAttr('hardwareRenderingGlobals.threadDGEvaluation', 1)
    cmds
.setAttr('hardwareRenderingGlobals.maxHardwareLights', 1)
    cmds
.setAttr('hardwareRenderingGlobals.transparencyAlgorithm', 0)

def main():
   
# Apply viewport 2.0 settings
   
print 'Apply custim settings for Viewport 2.0'
    set_vp2_settings
()
   
# Disabling viewport
   
#mel.eval("paneLayout -e -manage false $gMainPane")


   
# Switch to Viewport 2.0
   
print 'Switching to use Viewport 2.0'
    mel
.eval('ActivateViewport20;')
   
   
# Enable back viewport
   
#mel.eval("paneLayout -e -manage true $gMainPane")
    
print 'Done!'


main
()



When I am running the code, it will print out all the print statements including the last one - Done!, but as soon as the last print statement is done, it is then I will be seeing 'Viewport2.0 Processing' on the bottom lefthand corner, which may take about a min to 2.
I tried disabling and re-enabling the viewport, still, viewport 2.0 only seems to get processed after the whole code execution.

In my main() function, I am expecting the `mel.eval('ActivateViewport20;')` to finish the processing before it prints the `Done!` statement, and hence I am asking about 'catching' ot..

Michael Boon

unread,
May 30, 2017, 6:12:06 PM5/30/17
to Python Programming for Autodesk Maya
The cmds equivalent of MEventMessage is 
cmds.scriptJob(event='idle', fn)
I haven't used it for a very long time but I think the fn might need to be a string representing MEL code.

Or you might be better off with evalDeferred:
cmds.evalDeferrred('print "a"')
cmds.evalDeferrred('print "b"', lowPriority=True)
cmds.evalDeferrred('print "c"', lowestPriority=True)

None of this is exactly what you want, I know. I looked into it briefly last year and didn't see any simple way to do it.

likage

unread,
May 31, 2017, 2:44:03 PM5/31/17
to Python Programming for Autodesk Maya
The cmds equivalent of MEventMessage is 
cmds.scriptJob(event='idle', fn)
I haven't used it for a very long time but I think the fn might need to be a string representing MEL code.

Or you might be better off with evalDeferred:
cmds.evalDeferrred('print "a"')
cmds.evalDeferrred('print "b"', lowPriority=True)
cmds.evalDeferrred('print "c"', lowestPriority=True)

None of this is exactly what you want, I know. I looked into it briefly last year and didn't see any simple way to do it.

Hi Michael, thanks for the information, appreciate it. No worries about that, I was simply looking to see if there is a way to 'catch' the end of the vp2 processing...
It also does seems a bit hard in my case if I am dealing with different poly counts, just realizing that when I was opening a very heavy scene file as the 'viewpoint 2.0 processing' message pops up every now and then as I tried to unhide new geometries or doing some viewport navigation. 
Reply all
Reply to author
Forward
0 new messages