PDA

View Full Version : calling python from maya does not work anymore..


Sorath
03-08-2011, 07:27 PM
I'm trying to call inside a standalone mel script for submitting to the farm a python script..
and messing around for hours now.. wtf is wrong with this???

import sys sys.path.append('L:/_deadline/submission/Maya')
import checkGamma
checkGamma.gamma()


# Error: AttributeError: 'module' object has no attribute 'gamma' #

like that what I try from within mel

python("import checkGamma"); python("checkGamma.gamma()");


and the python code I am calling inside mel is this:


import maya.cmds as mc

def global gamma():
cams = mc.listCameras (p=True)

for i in cams:
isRenderable = mc.getAttr (i + '.renderable')
if isRenderable == True:
lensShader = mc.listConnections (i + '.miLensShader')
gamma = mc.getAttr (lensShader[0] + '.gamma')

if not gamma == 1:
request = mc.confirmDialog (title='note', message='gamma is set to 2.2 change to 1.0', button= ['yes', 'no'], defaultButton='yes', cancelButton='no', dismissString='no')
if request == 'yes':
mc.setAttr (lensShader[0] + '.gamma', 1)
print 'gamma was set to 1'
else:
print 'your lensShader is set to Gamma %s' %gamma
continue
else:
print 'your lensShader is set to Gamma %s' %gamma
continue


very thankfull for input!~

nessus
03-08-2011, 08:50 PM
You sure the py code can run fine?
def global gamma()?? really? I have never seen this.

Sorath
03-09-2011, 08:50 AM
it doesn't matter what I name my function.
global because It seems only to work like that when you source it from within mel.. (acc. to internet)..

earlyworm
03-09-2011, 10:22 AM
Does your def global gamma() function even work if you run it by itself? I get syntax errors when I try to define a function with global in there like you've put - I also never seen it used in python - could you point out the link where you saw this information?

NaughtyNathan
03-09-2011, 10:39 AM
I think you must be getting mixed up between MEL and python Sorath, you don't "source" python from "within MEL"... I'm with earlyworm, def global is probably the problem...

:nathaN

Sorath
03-10-2011, 10:53 AM
hmm.. ok, I think I really messed something up here.
nevermind I integrated my check routines directly in the submit script.. and called all other mel stuff with maya.mel.eval

CGTalk Moderation
03-10-2011, 10:53 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.