Author Topic: set environment variables with simpleCMD  (Read 10375 times)

wingart

  • Jr. Member
  • **
  • Posts: 8
set environment variables with simpleCMD
« on: August 23, 2017, 10:25:04 PM »
I need to set a few environment variables to load up vray before rendering like so:

SET VRAY_PATH=\\server\vray\35203_maya2016
SET VRAY_AUTH_CLIENT_FILE_PATH=%VRAY_PATH%
SET VRAY_FOR_MAYA2017_MAIN_x64=%VRAY_PATH%\maya_vray
SET VRAY_FOR_MAYA2017_PLUGINS_x64=%VRAY_PATH%\maya_vray\vrayplugins
SET VRAY_OSL_PATH_MAYA2017_x64=%VRAY_PATH%\vray\opensl
SET VRAY_RENDER_DESC_PATH=%VRAY_PATH%\maya_root\bin\rendererDesc

How do I hardcode it inside mayabatch.py?

cmdjob.properties.env['key1']='value1'
cmdjob.properties.env['key2']='value2'

thanks.

jburk

  • Administrator
  • *****
  • Posts: 493
Re: set environment variables with simpleCMD
« Reply #1 on: August 24, 2017, 08:12:15 PM »
You can do this in the existing preSubmit() function in mayabatch.py:

Code: [Select]
def preSubmit(cmd, job):
    # Handle renderer-specific callbacks
    if cmd.package['-renderer'] == 'mi':
        return preSubmit_mi(cmd, job)
    elif cmd.package['-renderer'] == 'turtlebake':
        return preSubmit_turtlebake(cmd, job)
   
    job['env'] = {
        'foo': 'bar',
        'foobar': 'bat'
    }



wingart

  • Jr. Member
  • **
  • Posts: 8
Re: set environment variables with simpleCMD
« Reply #2 on: August 25, 2017, 10:25:58 PM »
thanks, i will give that a try.