[Closed] TEMP folder for different versions of max
It was very strange today to fins out that
3dmax 2012 writes and reads files from sysInfo.tempdir (in my case C:\TEMP) but
3d max 2014 gives unknown at
openfile (sysInfo.tempdir + "\ est.dat") -- undefined for 2014
openfile ("C:\ est.dat") -- is working ok with both
I don’t know why this happens, but I need a folder for different versions of max for a temp variable to be able to get it from there. Please tell me who knows such a place
What about the 3dsMax temp folder:
pathConfig.GetDir #temp
For 3dsMax 2014 tha path is:
“C:\Users\You_User_name\AppData\Local\Autodesk\3dsMax\2014 – 64bit\ENU emp”
For 3dsMax 2012:
“C:\Users\You_User_name\AppData\Local\Autodesk\3dsMax\2012 – 64bit\enu emp”
Choose which temp folder to use and use it with other version of 3dsMax. If there only one user that will use the PC there should be no problems. If there are multiple user accoutns, then there will be problems.
Thank you, miauu. The thing is that I know about this location. I mean an universal TEMP folder for any max version.
I have just found which is the real problem.
sysInfo.tempdiris good, but the problem is with the openfile.
If I create a file in max 2012 and close it, then when I open it in 2014 it gives unknown.
Code for max 2012
f= createfile (sysInfo.tempdir + "\ est.dat")
format "%
" "2012" to: f
close f
Code for max 2014
f = openFile (sysInfo.tempdir + "\ est.dat") mode:"r"
if ConvMF!=undefined then
(
print (readLine f)
)
close f
)
Tell me please, what’s wrong?
I understand that It can’t read because it is busy. If I create with max 12 then I can read it in 12, and if I copy this file to another folder, then 14 reads it successfully.
Besides a missing parenthesis and an undeclared variable “ConvMF”, there is nothing wrong.
When you are working with file streams sometimes, if there is an error in your script and the file was not properly closed, you might not be able to open it with another application. However, you will be able to open it again with the application you created it. That’s why the file opens in Max 2012 and it does not open in Max 2014.
Not even flush() will always properly release the file, so to make sure the file was released from memory call gc() from the app you created it (in this case Max 2012) and then you are ready to open it from another app.
Thank you for your help, in fact I have no errors in my code, I just tried to simplify it here, so sorry about this.
I’ve tried with gc() after close f, and it still cannot be opened in 2014.
The only solution was to copy the file renamed and open the renamed file. It is sad that I cannot properly close it.
Have you tried closing Max 2012 before opening the file in Max 2014?
Other thing to try is with another file, copy any file to the temp folder manually and then try to open it with Max 2014, does it work? Can you read/write files in the temp folder from Max 2014 or this problem just happen with this specific file?
#1 Have you tried closing Max 2012 before opening the file in Max 2014? – Yes, when I close 2012, 2014 reads it
#2 copy any file to the temp folder manually and then try to open it with Max 2014, does it work – yes, it works
#3 Can you read/write files in the temp folder from Max 2014 or this problem just happen with this specific file? – Yes, It reads and writes files from/to this folder
Well, that’s really estrange. It does work on my end as I would expect.
Seems that indeed Max 2012 is somehow locking the file, as if you close it you are able to read the file from Max 2014.
Let’s start fresh:
- Close all Max instances you are running
- Start Max 2012 and 2014
- In Max 2012 run this Script (you should get no errors)
(
filename = sysInfo.tempdir + "\ est_001.dat"
file = createfile filename
format "%
" "2012" to:file
flush file
close file
)
- Switch to Max 2014 (don’t close Max 2012) and run this:
(
filename = sysInfo.tempdir + "\ est_001.dat"
file = openFile filename mode:"r"
if file != undefined then
(
print (readLine file)
close file
)else(
messagebox "Can't open file"
)
)
Doesn’t it work?
Hi, Jorge!
I closed all Max instances.
#1. If I open both – 2012 and 2014, then 12 writes, but 14 gives messagebox “Can’t open file”
#2. If I run the script for 2012 and close 2012, then 2014 reads the file.
#3. If I write in one instance of max 2012 and dont close it, then other instance of 2012 reads it, but 2014 doesnt read
If using free() or gc() won’t work, then it might be a permission/security issue.
Perhaps you could check/set those properties with C# and see if that solves the problem.
Does it work if you do it the other way, write the file from Max 2014 and read from Max 2012?
Time to call the Doctor I guess.