Change render file name prefix with python

Change render file name prefix with python

InvisioMedia
Contributor Contributor
1,434 Views
3 Replies
Message 1 of 4

Change render file name prefix with python

InvisioMedia
Contributor
Contributor

Hi,

 

  our scripts before were setting the render file name prefix with python from the scene name, but lately it doesn't work anymore.  Can you tell me how to achieve that please?

 

Many thanks

0 Likes
1,435 Views
3 Replies
Replies (3)
Message 2 of 4

Kahylan
Advisor
Advisor

Hi!

 

That depends on how the render gets triggeret in the script. Would you mind posting the code snipped that names the rendered files and starts the render?

0 Likes
Message 3 of 4

InvisioMedia
Contributor
Contributor

 

cmds.setAttr('defaultRenderGlobals.imageFilePrefix', '<RenderLayer>/<Version>/%s_%s_%s_<RenderLayer>_<Version>'%(project,seq,sceneName), type='string')

 

For some reason it was working all the time before, and not anymore.  I am wondering if a change in the maya api has affected this, I know new tokens were introduced as well at some point.

 

0 Likes
Message 4 of 4

Kahylan
Advisor
Advisor

Hi!

 

The code you posted works. But depending on what renderengine you are using, the acutal renderer could overwrite the name. Did you change anything in that regard?

 

Also I can't see the way you are defining your "sceneName" variable, since that one seems to be the one causing problems. When I need the scene name as a variable I usually use the os library to do so. Something like this:

import maya.cmds as cmds
import os

filepath = cmds.file(q=True, sn=True)
filename = os.path.basename(filepath)
sceneName, extention = os.path.splitext(filename)

 

Are there any specific errors you get when you try to rename your file prefix?

0 Likes