Eddy Khemiri
Eddy Khemiri

Reputation: 111

maya what is the equivalent of the mel commands getenv and putenv in python?

In Maya, how can I use Python to achieve the same functionality as the MEL commands getenv and putenv? i've tried to import maya.mel but it doesn't have a getenv or putenv argument: import maya.mel as mel mel.getenv('ARNOLD_PLUGIN_PATH') ie returns

Error: AttributeError: file line 2: module 'maya.mel' has no attribute 'getenv'

Upvotes: 0

Views: 199

Answers (1)

Eddy Khemiri
Eddy Khemiri

Reputation: 111

problem solved using the maya.mel.eval command:

userSetup.py

import maya.mel as mel

X3_PATH="G:/Mon Drive/EDDY ALL WORK/3.0/Eddy3ree/Eddy3ree_01"

path=mel.eval('getenv ARNOLD_PLUGIN_PATH')+';'+X3_PATH # get path

mel.eval(('putenv ARNOLD_PLUGIN_PATH \"'+path+'\"')) # set path

print(mel.eval('getenv ARNOLD_PLUGIN_PATH')) # print path

Upvotes: 0

Related Questions