View Full Version : executePythonCommand in C++

04 April 2009, 01:51 AM
Hi people .. i have a Q
is there a way to execute a Python Command inside C++ some one told me that i can use the executePythonCommand from MGlobal.h i saw it in the API document in maya2009 but it says under it "This method is not available in Python" is that mean that its not working ?
can i run that in this code sample ? and wut changes i should add to it for it to work .. thank you.

#include <maya/MSimple.h>
#include <maya/MIOStream.h>
#include <maya/MGlobal.h>
#include <maya/MLibrary.h>

DeclareSimpleCommand( saed, "Autodesk", "2009");

MStatus saed::doIt( const MArgList& args )


cout << "Hello "<< endl;// in the output window

int saed = 2;
int saed2 = 3;

cout<<saed+saed2<<endl;// in the output window

MGlobal::displayInfo("King nothing");// in the script editor
MGlobal::executePythonCommand("print 66",true);// not working
MGlobal::executeCommand( "print \"Hello world!\\n\"", true );// using mel

return MS::kSuccess;


04 April 2009, 04:33 AM
that message means it's not available if using the python api bindings. it works fine with c++ api.


04 April 2009, 10:32 PM
thankx alot my Friend :)

CGTalk Moderation
04 April 2009, 10:32 PM
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.