cyclops cyclops - 1 year ago 199
Python Question

set render images path in maya by python

I want to render images in specific location in Maya 2015.

for that i want to set the image output path by python (pymel or cmds).

import maya.cmds as cmds
import pymel.core as pm
path = r"D:\my_renderpath"
pm.mel.eval(r' setProject "{}"'.format(path))

with above code i am able to change the project directory that gives me very close result.

but Still "Images" variable in project window is set to images.

How can i add "D:\my_renderpath" in Images of Project Window.

Answer Source

To change the Image path in maya project window i found this way.

create a workspace.mel file and set project.

import pymel.core as pm
#  Create a workspace MEL file
path = "D:\\my_renderpath"    
workspace = '//Custom Maya Project Definition' \
            '\n' \
            'workspace -fr "images" "{}";'.format(path)
workspace_file = r'{}\workspace.mel'.format(path)
with open(workspace_file, 'w') as job_file:
#  Set Render  path as Maya Projects
pm.mel.eval(r' setProject "{}"'.format(path))
# save maya file

This works fine.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download