PDA

View Full Version : Source MEL in Python


ruchitinfushion
11-05-2011, 06:45 PM
Hello i m getting this error:

# Error: TypeError: file C:\Program Files\Autodesk\Maya2012\Python\lib\site-packages\maya\app\commands.py line 17: Object is invalid #

After running this code

mc.eval('source "D:/Scripting/Dynamics/cra_sprObjects.mel;"')


And


string = 'source "D:/Scripting/Dynamics/cra_sprObjects.mel;"'
mc.eval(string)


So,Tell me wht's wrong i am doing??Reply ASAP.Thank you

NaughtyNathan
11-05-2011, 08:43 PM
I assume mc is maya.cmds right? if so, you're using the wrong module. I have no idea wtf cmds.eval is for, but I can't get it to do anything. If you want to execute MEL code you have to use the maya.mel module:
import maya.mel as mel
mel.eval('source "someScript.mel"'):nathaN

ruchitinfushion
11-06-2011, 05:47 AM
Oh no that was very silly mistake( importing wrong module),Anyway now it's working fine with
Import maya.mel as mel
instead of
Import maya.cmds as cmd
Thanx much for pointing in right direction.
Working code

Import maya.mel as mel
mel.eval('source "D:/Scripting/Dynamics/cra_sprObjects.mel"')
mel.eval('cra_sprObjects()')

CGTalk Moderation
11-06-2011, 05:47 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.