std::string loadTextFile(const std::string& filePath)
{
std::ifstream file;
file.open(filePath.c_str());
std::string output;
std::string line;
if (file.is_open())
{
while (file.good())
{
getline(file, line);
output.append(line + "\n");
}
}
else
{
std::cerr << "Unable to load file: " << filePath << std::endl;
}
return output;
}And then in initializePlugin() I invoke loadTextFile() and pass my string object as an argument using .c_str() method in MGlobal::executePythonCommand(). But when I build my .mll file and try to load that in Maya I get error message from my loadTextFile() function: Unable to load file...
My first guess is that the .txt file is in wrong place. For now, just for testing purposes, I have simple test.txt file with just one line of code: print "Hello!" and as an argument I pass "text.txt" to the loadTextFile() but I've tried to put that file in different folders, starting with the most obvious: in the same folder where my source files and header files are, in the folder where my .mll file is... but none of those works and I get the same message.std::ifstream ifs("myfile.txt");
std::stringstream stream;
stream << ifs.rdbuf();
return stream.str();
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/c2a85735-a2e3-48a7-9cf9-54368ddb8e30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/c2a85735-a2e3-48a7-9cf9-54368ddb8e30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/fe23dadb-b36a-4773-bbbd-352a4bb8cbb7%40googlegroups.com.