load render preset with python issue

load render preset with python issue

Anonymous
Not applicable
3,500 Views
7 Replies
Message 1 of 8

load render preset with python issue

Anonymous
Not applicable

Hey I have an issue with scripting in maya with python. I want to load a custom renderpreset from a txt file but it only semi works.Reading the highlighted text from the notepad txt fileReading the highlighted text from the notepad txt file

If I select a different renderer and go back to the maya softwarerenderer it has the correct settings.showing it works if I toggle the assigned renderershowing it works if I toggle the assigned renderer
The error stops the execution of the rest of the script though so I can't work with this!

Error: TypeError: file D:\Program Files\Autodesk\Maya2018\Python\lib\site-packages\maya\app\renderSetup\model\renderSetup.py line 700: Unknown keys found in the dictionary: mayaSoftware #

Used almost exact copy of this code:
http://around-the-corner.typepad.com/…/how-to-importexport-…

 

Can someone help me? It's pretty urgent..

0 Likes
Accepted solutions (1)
3,501 Views
7 Replies
Replies (7)
Message 2 of 8

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

I tried to reproduce the issue but failed. Could you send me a sample for reproducing the issue? It looks like rendersetup didn't find mayaSoftware render on your system and could be an environment setting problem.

 

Yours,

Li

Message 3 of 8

Anonymous
Not applicable

 

from maya import cmds
import maya.app.renderSetup.model.renderSetup as renderSetup

import json

filename = "C:\Users\name\Documents\maya\Presets\TestPreset.json"

def importRenderSetup(pFilename):
    with open(pFilename, "r") as file:
        renderSetup.instance().decode(json.load(file), renderSetup.DECODE_AND_OVERWRITE, None)

importRenderSetup(filename)

 This is what I do in short, thanks for replying!

0 Likes
Message 4 of 8

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

It looks same as my test code.

 

import maya.app.renderSetup.model.renderSetup as renderSetup

import json

def importRenderSetup(filename):
    with open(filename, "r") as file:
        renderSetup.instance().decode(json.load(file), renderSetup.DECODE_AND_OVERWRITE, None)
 
       
importRenderSetup("e:/rendersetup.json")

The '\' character inside your path looks suspicious, it could escape some of characters in your filename path. Please try to replace them with '/'.

 

If that wouldn't work, it might be some special use case in the exported template. Could you send a copy of TestPreset.json to me?

 

Yours,

Li

Message 5 of 8

Anonymous
Not applicable

Fixing the slash direction didn't change anything. Sent the files. 

0 Likes
Message 6 of 8

Anonymous
Not applicable
Accepted solution

I fixed it by updating maya and adding missing code that  to the preset json file.

{ 
//Adding these into your file.
{
        "renderSetup": {
    "name": "renderSetup", 
    "renderLayers": []
  }, 
  "sceneAOVs": {}, 
  "sceneSettings": {
...
} // an extra bracket
}
}
Message 7 of 8

Anonymous
Not applicable

Can you please post the full code that was provided? I have the same issue.

Message 8 of 8

Anonymous
Not applicable

Is there a solution to this? Tried using your code and still getting TypeError