Change viewport renderer with Python API

440 views
Skip to first unread message

Andrew Golubev

unread,
Aug 23, 2021, 5:26:25 AM8/23/21
to Python Programming for Autodesk Maya
Hello everyone!

Stuck with some problem, using maya 2017, and i need to change viewport rendere to viewport 2.0, how can i do this with Python API?
Cannot find such option in documentation,
what i founded i can check what RendererName currently used as enum parameter of
M3dView  object of current viewport with getRendererName(), but there is no setRenderer , and i cannot change param directly without setter.

TTw TTa

unread,
Aug 24, 2021, 11:55:46 PM8/24/21
to Python Programming for Autodesk Maya
you could use mel function 

setRendererInModelPanel $gViewport2  your_model_panel   # viewport 2.0

setRendererInModelPanel $gLegacyViewport  your_model_panel  ;  # viewport 1.0






Andrew Golubev

unread,
Aug 25, 2021, 5:06:55 AM8/25/21
to Python Programming for Autodesk Maya
Hi! Thank you for reply!
Currently i'm using almoust the same as you written, 
but with python and cmds: cmds.modelEditor() command with proper flags.

I was intrested how to do the same operation with Python API

среда, 25 августа 2021 г. в 06:55:46 UTC+3, wwn150...@gmail.com:

TTw TTa

unread,
Aug 25, 2021, 7:59:10 AM8/25/21
to Python Programming for Autodesk Maya
because the document said the Maya c++ api doest contains all function with maya,you must combine it with mel ,so I think it may like that

om.MGlobal.executeCommand("setRendererInModelPanel $gViewport2  your_model_pane")
Reply all
Reply to author
Forward
0 new messages