[Closed] Save/Load render preset (.rps) inside maxfile. Possible?
Is it possible to save/load a binary file inside of max file?
For example. render preset file and uvw file.
something like this ?
fn EncodeOnRootNodeDemo =
(
if (fname = getOpenFileName caption:"load UVW" types:"UVW File(*.uvw)|*.uvw|" ) != undefined then
(
if (fstream = fopen fname "rb") != undefined then
(
fseek fstream 0 #seek_end
maxlen = ftell fstream
fseek fstream 0 #seek_set
ss = StringStream ""
for i = 1 to maxlen do print (ReadByte fstream #unsigned) to:ss
fclose fstream;
)
-- attach it to root node appdata
setappdata rootnode 666 ss
-- now the proof
savemaxfile "this_is_appdata_test.max"
resetMaxFile #noPrompt
loadMaxFile "this_is_appdata_test.max"
ss = StringStream (getappdata rootnode 666);
if (fstream = fopen ((getFilenamePath fname) + "new.uvw") "wb") != undefined then
(
while not eof ss do WriteByte fstream (readvalue ss) #unsigned
fclose fstream;
)
)
)
EncodeOnRootNodeDemo();
OK… finally I had time to play with your code.
This is what I’m trying to do.
I want to run renderpresets.Save command and save *.rps data in the scene.
The problem is that I don’t want to save temp rps file on the drive.
I want to put the data directly into appdata.
Then I want to load the appdata using renderpresets.Load[i]
Thanks.
[/i]
think you are always going to have to use temp files somewhere along the line but they can be deleted once they have been used as the data will reside in the max file.
saving could be like…
save the rps as a temp file.
read back in and attach to the rootnode
delete the rps file.
restoring would then be…
write the rps from the rootnode data to temp rps file
load the temp rps file
delete temp rps file