Search code examples
pythonarraysjsonmaya

Assigning Maya render settings manually from json data


I want to apply a dictionary of key/value data from a json file into Maya's render settings.

Currently, I have a dictionary of 16 items formatted as follows:

{u'defaultRenderGlobals.blurSharpness': 1.0, u'defaultRenderGlobals.enableDefaultLight': False}

I can now convert to a list, however I am unsure how exactly I should loop through the data and assign it to the correct attributes inside Mata using cmds.setAttr() command.

Could anyone suggest a good method to assign? I am aware that Maya has it's own function to load a full render setup json, but here I am looking for a way so assign only certain arrays as required.

Thank you,

Craig


Solution

  • I don't use Maya, so I can't test this, but it sounds like you want something like

    for k, v in settings.items():
        cmds.setAttr(k, v)
    

    where settings is your 16-item dictionary of settings.