I think it might be easier to run EVERYTHING deferred, so that you can be
SURE that things execute in the order you want them to - ie, do something
like this:

def doMyThang():
    pm.runtime.ActivateViewport20()
    renderer = pm.modelEditor(editor, q=True, rendererDeviceName=1)
editor = panel.getModelEditor()
pm.evalDeferred(doMyThang)

If that doesn't work, you can try breaking it up into two parts:


def part1():
    pm.runtime.ActivateViewport20()
    pm.evalDeferred(part2)
def part2():
    renderer = pm.modelEditor(editor, q=True, rendererDeviceName=1)

editor = panel.getModelEditor()
pm.evalDeferred(part1)

Of course, this means you won't back the answer to what the renderer is in
the original context - but if processing of idle events is required first,
it might make sense to design things so that it puts things in an
intermediate state, and then "updates" once it can get access to the
"right" answer.

If you absolutely need it in the original context, though, you could also
try maya.utils.processIdleEvents()...

- Paul

On Mon, Aug 4, 2014 at 12:38 AM, Justin Israel <[email protected]>
wrote:
> Untested, but have you checked if the refresh command helps to flush the
> event queue?
>
http://download.autodesk.com/global/docs/maya2012/en_us/CommandsPython/refresh.html
>
> Otherwise I am pretty sure using the qt processEvents() call would work:
>
> from PySide import QtGui
> QtGui.qApp.processEvents()
>
> On 4/08/2014 6:38 PM, "Michael Boon" <[email protected]> wrote:
>>
>>
>>
>> Hi all,
>>
>> I'm trying to load a DX11 shader. In the process I have to make sure
VP2.0
>> is on and the renderer is set to DX11.
>>     editor = panel.getModelEditor()
>>     pm.evalDeferred("pm.runtime.ActivateViewport20()")
>>     renderer = pm.modelEditor(editor, q=True, rendererDeviceName=1)
>> ActivateViewport20 only works if deferrred, probably because I just
>> created the panel.
>> As it is, renderer gets set to an empty string. If I wait a moment (eg if
>> I run it line by line in the script editor), renderer returns
>> 'VirtualDeviceDx11' as appropriate.
>>
>> So basically, I think I need to defer twice. Once before
>> ActivateViewwport20, and again between that and getting the
>> rendererDeviceName. I've tried this:
>>     editor = panel.getModelEditor()
>>     pm.evalDeferred("pm.runtime.ActivateViewport20()")
>>     pm.refresh(force=True)
>>     renderer = pm.modelEditor(editor, q=True, rendererDeviceName=1)
>> with no luck. I've also tried time.sleep(), but that halts Maya's main
>> thread, which doesn't help at all.
>>
>> Is there a way to give control back to Maya's event loop until it's idle,
>> with writing a state machine?
>>
>> (This is in Maya 2015.)
>>
>> Thanks,
>>
>> Boon
>>
>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>>
https://groups.google.com/d/msgid/python_inside_maya/221422dd-df4e-40ae-9f98-cef8cc501f1c%40googlegroups.com
.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> 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 [email protected].
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1hB4xSfnAxx-rMgmesOvOJ9exDTmuRCUMSrLXLOSFHQA%40mail.gmail.com
.
>
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAAssL7Zgp%2BkbwqB-GR9qqeac0P2uU89ddBVmcChPO%3DnogDngYA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to