userSetup adjustments for Arnold?


#1

Hello everyone,

     I'm trying to make some adjustments to our userSetup.mel so that we can automatically set the Arnold Render Settings to turn off Auto-Convert Textures to TX and then lock the menu. 

I’ve tried adding the following already:

evalDeferred(“setAttr “defaultArnoldRenderOptions.autotx” 0”);
evalDeferred(“setAttr -l true { “defaultArnoldRenderOptions.autotx” }”);

But this didn’t work.

I’ve also tried adjust the following as well for our userSetup.py file:

def doSettings():
print(“Disabling Arnold Auto Convert…”)
cmds.setAttr(“defaultArnoldRenderOptions.autotx”, 0)
cmds.setAttr(“defaultArnoldRenderOptions.autotx”, 1=True)

And again, no luck.

Any advice on what to change to make this happen would be greatly appreciated.

Thanks again.


#2

It is possible that the arnold render nodes are not yet available at the time the userSetup is executed. Setting such attribtes in the userSetup is not very useful anyway because it only works once. So even if it would work, it would do it only the very first time. As soon as you open another scene or make a new one, the settings are gone.

What you need is a callback which is called every time a scene has been opened or a new one has been created. Or one which is called if an object has been created. Have a look at the scriptJob command. But scriptJobs only work from within the UI, if you need something which works in batch as well, you can use the python maya API and create the correct callbacks, but that’s a little bit more complicated.


#3

Haggi,

     Thanks for replying to my thread. 

I’m only wanting to do this within the UI. I’ve already come up with a way to get my renderfarm to set this command in a prerender script.

From trying a bunch of combinations with userSetup and evalDeferrred, none of that works. I’m seeing Arnold as pretty much the last thing to load, so I can only assume this they wont work.

If I go with trying a ScriptJob command, what event should I be looking for to run the setAttr commands? Is there a way to find that out?


#4

You could try a “NewSceneOpened” event to enable it in case a new scene is created and addiptionally a “SceneOpened” event. But there is no guarantee that the arnold globals nodes already exist if the scriptJob is executed. I’d recommend to create these nodes if necessary. This should work with:

import mtoa.core
mtoa.core.createOptions() 

Or if you want to use it from mel:

python("import mtoa.core;mtoa.core.createOptions()")

This way you make sure that the nodes exist.