#include// Construct a file path string with the given scene name MString sceneName = "myScene.ma"; MString filePath = MString::format("/path/to/scenes/{0}", sceneName); // Print the file path string to the console std::cout << filePath.asChar() << std::endl;
#includeHere, we use the `format` static method again to create a message string that includes the values of `meshName` and `numVertices` as substrings. The `{0}` and `{1}` placeholders in the format string are replaced by the corresponding variable values. Overall, MString is a useful utility for constructing formatted strings in Maya C++ plugins and scripts. It is part of the MLibrary package in the Maya API.// Create variables to include in the message string int numVertices = 100; MString meshName = "myMesh"; // Format the message string with the variables MString message = MString::format("Mesh {0} has {1} vertices.", meshName, numVertices); // Print the message string to the console std::cout << message.asChar() << std::endl;