Jim
Jim

Reputation: 89

Maya – Setting frame range programmatically with the Render Setup API

I am trying to set the Start frame with the renderSetup Python api in Maya 2022 like this:

import maya.app.renderSetup.model.override as override
import maya.app.renderSetup.model.selector as selector
import maya.app.renderSetup.model.collection as collection
import maya.app.renderSetup.model.renderLayer as renderLayer
import maya.app.renderSetup.model.renderSetup as renderSetup
import maya.cmds as cmds

rs = renderSetup.instance()  
rl = rs.createRenderLayer('NewLayer')
sf = rl.createAbsoluteOverride('defaultRenderGlobals', 'startFrame')
sf.setAttrValue(20)

enter image description here

For some reason the value '20' gets translated in '0.0800'. How to set it to the proper value?

Upvotes: 1

Views: 1174

Answers (1)

Andy Jazz
Andy Jazz

Reputation: 58493

0.004 frame issue

It's a Great Old Issue of Maya's Render Setup editor. Use additional multiplier 250, because initial frame value for some reason is still 0.004 frame. Use the following math if you need a frame 20:

0.004 x 20 x 250 = 20

The only possible explanation for this nonsense is the implementation of a preset with a frame rate of 23.98 fps instead of 23.976 fps. This is where Maya engineers "lost" 0.004 frame. This is my thought and it may be wrong but as Final Cut Pro evangelist, I admit that thought...

So, according to your code you need to write this:

sf = rl.createAbsoluteOverride('defaultRenderGlobals', 'startFrame')
sf.setAttrValue(20*250)

Upvotes: 1

Related Questions