Notifications
Clear all

[Closed] How to Read/SAve File contents

Wouldn’t it be easier to store the file’s path?

nope, because i need the reder preset travel with the file, i mean if i send you the max file, and you open it inside your computer, you will be able to load one of my render presets with a little script.

I understand. Then, for one thing, are you sure you are not just asking for the first line of the strignstream? And also, again, wouldn’t it be easier to just use a persistent global variable?

From the MXS reference:

“MAXScript supports a limited form of persistent global variables. You declare a particular global to be persistent and the value it contains is always saved to and restored from scene files as they are opened and closed. Therefore, you can keep direct references to objects in the scene in variables and those references will persist across scene save and reload.”

i’m going to check the persistent global variables, but maybe you are right and i’m reading only the first line, i’m using the code that denisT posted, it use and “while EOF …” so i though that it would read all the lines, how can i read/write all the lines if is not with this method?
Going to check the global variables.

Thanks.

The problem that i see with the persistent global variables is that i can end up with a lot of global variables in the scene, wich i think is bad (i’m not sure, but i think that)

I think that the best way to go is to store the complete file inside a data channel of an object, for my script i have some specific objects that i create and erase, so i want to store the data inside this objects, the thing is that i cannot get to read the entire file, and to write the entire file.

What do you think?

I tested with a normal txt file and i read it all, but when i try with my render preset it only reads the first characters weird

I tried everything, even binstream, nothing seems to work, i don’t know what to do, i detected that max says that the end of the file is at a few characters from the begginig, i don’t understand…i’m a bit desperate hehe.

Cheers.

can you attach any of your presets files?

Yes, it’s a normal render preset from max, with mental ray, i did nothing to them,

Here you have one.

It’s ziped due to the extension restrictions.

Thanks.

It’s binary format file… I gave you functions to write and read text files. To read and write binary files you have to use another methods. I will try to find a solution…

Page 2 / 5