Hi there, I've been banging my head trying to get this working for a while now, so hopefully someone can help me.
MAC OSX Sierra
Maya LT 2017
I would like to write to a txt file using MEL, but I keep getting the error "Unable to open file... with permission "w""
I pulled the example code out of the documentation, and I can't even get "Hello World" to work.
proc fileWrite(){ // Open a file for writing, the default behavior of the command $filePath = "/Path/to/file/"; $exampleFileName = ( $filePath + "example.txt" ); //check permissions $dirChk = `filetest -w $filePath`; $fileChk = `filetest -w $exampleFileName`; print ("Dir Check: " + $dirChk + "\n"); print ("File Check: " + $fileChk + "\n"); $fileId=`fopen $exampleFileName "w"`; fprint $fileId "Hello World"; fclose $fileId; } fileWrite();
This could be a MAC issue, but as you can see from the code, I'm using "filetest" to check permissions and it says I have write access on the directory and the file.
I can read a file, so I know my path is correct... just can't write or append.
I don't know what else to try.
Any ideas?
Thanks!
Solved! Go to Solution.
Solved by christiej. Go to Solution.
Hello,
Please look at the mel commands fwriteAllLines and fwriteAllText that allow you to write to file from Maya LT.
These commands will also work in Maya.
You can refer to this section in the Maya LT documentation:
http://help.autodesk.com/view/MAYALT/2017/ENU/?guid=GUID-7D50AA7D-DA27-4D7F-BE15-F0F428E40755
-Christie
Thank You Christie!
Yes, those work perfectly.
I keep forgetting that LT is not the same as full Maya. 🙂
Thanks again
-Irv
Can't find what you're looking for? Ask the community or share your knowledge.