-2

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.

Rajiv Sharma
  • 6,746
  • 1
  • 52
  • 54

4 Answers4

2

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:
    job_file.write(workspace)
#  Set Render  path as Maya Projects
pm.mel.eval(r' setProject "{}"'.format(path))
# save maya file
pm.system.saveFile()

This works fine.

Rajiv Sharma
  • 6,746
  • 1
  • 52
  • 54
2

You want the workspace() command

theodox
  • 12,028
  • 3
  • 23
  • 36
2
import pymel.core as pm
pm.mel.setProject("your/project/path")
Hal
  • 41
  • 3
1

If I ONLY want to set the images location, which is typically all i ever do (favoring my own pipeline over maya's)

#import pymel lib
import pymel.core as pm

#declare target render dir
render_dir= r'some\path\here'

#define workspace file rule for images
pm.workspace(fileRule=['images',render_dir])
Ari Gold
  • 1,528
  • 11
  • 18
Tom Mikota
  • 11
  • 3