Maya API How-To #23

Back · Previous · Next Maya

How can I see the contents of an MString when debugging in .NET?


Here's the original thread for this topic from Highend3D.com:

First, edit the MString.h header in the "include" folder in Maya's SDK. In the declarations section near the top of the file add the following definition:

struct MStringData
{
  int refCount;
  int length;
  int pad;
  char mayastring[];
};

Note: This relies on sizeof(int) == 4.

In the private section of the MString class replace the (void*) declaration for api_data.

private:
// before
  // void* api_data;

// replace with...
  MStringData* api_data;

You may also wish to add the following to the top of the file to suppress warnings which may now appear:

#pragma warning(disable: 4200)

If you'd like .NET to display MString contents in the pop-up tips that appear when you 'mouse-over' the variables then edit the following "autoexp.dat" file located in:

// .NET 2002
\Program Files\Microsoft Visual Studio .NET\Common7\Packages\Debugger\autoexp.dat
// .NET 2003
\Program Files\Microsoft Visual Studio .NET 2003\Common7\Packages\Debugger\autoexp.dat

Add the following two lines to the end of the file:

; for Maya 4.0
MString = <api_data->mayastring>

You'll need to restart .NET to have this take effect.


Acknowledgements

24 Jun 2004