View Full Version : Source MEL in Python

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

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

After running this code

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


string = 'source "D:/Scripting/Dynamics/cra_sprObjects.mel;"'

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

11-05-2011, 07: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

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"')

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.