View Full Version : Get latest open file?
f97ao 02-19-2007, 09:53 AM Is there a way to get the latest opened file in maxScript?
Also how about the latest autobackup.
All of them could be solved by reading from the Ini file but would be nicer wit a more direct approach.
/Andreas
|
|
Reading the INI file was my first thought, too.
It is pretty straight forward as you don't have to compile paths and bother about max versions [... maybe ...].
MerlinEl
02-19-2007, 11:18 AM
actionMan.executeAction 0 "203"
f97ao
02-19-2007, 12:21 PM
I used used the INI file like this:
lastFileName=getINISetting (getDir #maxRoot+"3dsmax.ini") "FileList" "File1"
shortFileName=getFilenameFile lastFileName
/Andreas
MerlinEl
02-19-2007, 05:42 PM
--First get autoback files:
backup_files = getFiles((GetDir #autoback)+"\\*.*")
autoback_files = for i in backup_files where (findString i "Autobak" != undefined) collect i
--Second Use a loop to compare flies modification date:
getFileModDate <filename_string>
f97ao
02-21-2007, 12:42 PM
--First get autoback files:
--Second Use a loop to compare flies modification date:
getFileModDate <filename_string>
Is there a simple way of comparing the dates? Right now the date is just a string and it's not formated well, so it takes quite some code to handle. For example it may say "5/1/1" as the date and later on it says 5/11/11. so the days can be both one or two letters long for example.
/Andreas
MerlinEl
02-22-2007, 07:10 PM
I made this for open last autoback. Its from my first begginer scripts.
I have no time to remake it , but for now is ok;)
Mabe you find some usefull there:
(--Start:
--> collect all autoback files
BackupFiles = (getfiles ((GetDir #Maxroot) + "\\autoback\\Autobak?.*"))
--> get the date on each file
if BackupFiles.count != 0 do
(
Files_Date = #()
Array_Date = #()
Array_Year = #()
Array_Month = #()
Array_Day = #()
Array_Hour = #()
Array_Minute = #()
Final_Check = #()
for i in 1 to BackupFiles.count do
(
--get file date => "7/13/2005 11:39:22 PM"
Files_Date[i] = (GetFileModDate BackupFiles[i])
--break date to parts => #("7", "13", "2005", "11", "39", "22", "PM")
Array_Date[i] = filterString Files_Date[i] "/ . :"
Array_Year[i] = (Array_Date[i] [3])--collect all years
Array_Month[i] = (Array_Date[i] [1])--collect all months
Array_Day[i] = (Array_Date[i] [2])--collect all days
Array_Hour[i] = (Array_Date[i] [4])--collect all hours
Array_Minute[i] = (Array_Date[i] [5])--collect all minutes
Final_Check[i] = (Array_Date[i] [5])--collect all minutes for final check
)
-----------------------------------------------------------------------
--> function for remove lower "date items" from array
fn DeleteLowerItemsIn arr =
(
maximus = arr.count
while maximus > 1 do
(
if (arr[1] as float) < (arr[maximus] as float) then
(
if Array_Year.count > 1 do (deleteItem Array_Year 1)
if Array_Month.count > 1 do (deleteItem Array_Month 1)
if Array_Day.count > 1 do (deleteItem Array_Day 1)
if Array_Hour.count > 1 do (deleteItem Array_Hour 1)
if Array_Minute.count > 1 do (deleteItem Array_Minute 1)
maximus -=1
)
else if (arr[1] as float) > (arr[maximus] as float) then
(
if Array_Year.count > 1 do (deleteItem Array_Year maximus)
if Array_Month.count > 1 do (deleteItem Array_Month maximus)
if Array_Day.count > 1 do (deleteItem Array_Day maximus)
if Array_Hour.count > 1 do (deleteItem Array_Hour maximus)
if Array_Minute.count > 1 do (deleteItem Array_Minute maximus)
maximus -=1
)
else if (arr[1] as float) == (arr[maximus] as float) do
(
maximus-=1
)
)
)
-----------------------------------------------------------------------
--> delete lower "date items" from array one by one
DeleteLowerItemsIn Array_Year
DeleteLowerItemsIn Array_Month
DeleteLowerItemsIn Array_Day
DeleteLowerItemsIn Array_Hour
DeleteLowerItemsIn Array_Minute
--> load last autoback file
Final_Pos = findItem Final_Check (Array_Minute[1]) --find the number pos in array
try (loadMAXFile (BackupFiles[Final_Pos]) )
catch (MessageBox "Open Autoback File is Failed" title:"Micra")
)--if BackupFiles.count != 0 do
)--End:
CGTalk Moderation
02-22-2007, 07:10 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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.