Message 1 of 1
creating shelf buttons conditionally with evalDeferred

Not applicable
09-13-2019
01:25 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm attempting to add buttons to a shelf based conditionally on available renderers, for example I attempted this inside my shelf .mel file...
if (`renderer -exists redshift`) { <create shelfButton> }
The above code could be used for vray also. The problem that I run into, though, is that maya tries to build shelves right off the bat before it's even aware of extra renderers like redshift or vray. For example, at the time that the shelf is being created, if I were to run the following MEL:
renderer -query -namesOfAvailableRenderers;
It would return:
mayaSoftware mayaHardware mayaHardware2
But when maya completely opens, I can run the same line in the script editor and get...
mayaSoftware mayaHardware mayaHardware2 redshift arnold mayaVector
I want to make my shelf buttons relevant to the renderers available. Is evalDeferred the answer here? If so, how exactly would I apply that in this case? I would love examples.