View Full Version : Maya API: How can I "print" a MObject?

10-02-2009, 12:44 AM
For learning API purposes, I am trying to convert the
closestPointCmd from the maya devkit from a command into a node.
However, I can get the intersector to work. Inside Maya I get the error message
Failed to create the intersector. Now for debugging purposes - and this might probably be
handy later on - to my actual question:

How can I print a MObject, or an MMatrix?
Something like :

MObject inMesh;
MGlobal::displayError( inMesh );

does not work for instance. How would I "convert" the Object into a String so that
I can feed it into the displayError or something that I can echo out?
Any ideas?

10-02-2009, 06:36 AM
You need to set the MObject into a MFn****.

MObject inMesh;
MFnDependencyNode nodeFn( inMesh );


MString nodeName = nodeFn.name();
MGlobal::displayError( nodeName );
MGlobal::displayError( nodeFn.name() );

no error cases:
MGlobal::displayInfo( nodeFn.name() );//print in script editor
cout << "inMesh: " << nodeFn.name().asChar() << endl;//print in output window

or something like that.

Hope it helps.

10-03-2009, 04:57 PM
Yeah! That worked!
Thanks a lot for the help :-)

CGTalk Moderation
10-03-2009, 04:57 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.