Community
Maya LT Forum
Welcome to Autodesk’s Maya LT Forums. Share your knowledge, ask questions, and explore popular Maya LT topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MEL write to txt file on Mac

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
i.bushnell
1127 Views, 2 Replies

MEL write to txt file on Mac

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!

2 REPLIES 2
Message 2 of 3
christiej
in reply to: i.bushnell

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 

 

 

Message 3 of 3
i.bushnell
in reply to: christiej

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.

Post to forums  

Autodesk Design & Make Report