Lost Adventurer, Aleks Kirilenko (3D)
LC #42 Pipers Alley

View Full Version : Edit maya ascii file (ma) with mel

11-11-2010, 02:11 PM
how can I edit a Maya ma file with mel? I know how to write and append a file with fprint. But how can I alter only a specific line in mel? I know how to get this line but I dont want to rebuild the whole file.

11-11-2010, 03:18 PM
If you want to just alter a character (or several) without changing the overall line length, you can do that by using fopen() as "wb", fseek() to the character position, and just use fwrite().

As far as I know, if you want to shorten or lengthen the line, then you will have to "rebuild" the file.

11-11-2010, 03:46 PM
actually I want to do something like this:

createNode surfaceShader -n "green";

createNode surfaceShader -n "red";

I couldn't find your suggestions in the help file. There is only "w" , "r" and "a". fseek does not exist.

11-16-2010, 07:12 PM
I don't know if this will help, but I had to repath reference directories on 25 files. I pretty much asked a coworker the same question as you did. He instructed me to install notepad++ and that has capability of batching a large number of text files. Since an ".ma" is basically a text file. I was able to batch the line change using that program. Beats writing a whole mel script that does the samething.

11-16-2010, 09:56 PM
Thanks for your answer. For editing references I am already using notepad++. The macro function by the way is pretty handy as well.

I found a way with python to do this.

CGTalk Moderation
11-16-2010, 09:56 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.