PDA

View Full Version : fullfilename + "localtime as string" how to write?


su37
04-08-2009, 02:04 PM
Hi all,

I have a question ,don't know how to do.
I want to renderout a tga file ,filename add localtime ,Want to some help
Similar this:

rendOutputFilename = fullfilename + "localtime as string" + ".tga"

DaveWortley
04-08-2009, 02:59 PM
maxfilepath + maxfilename + localtime + ".tga"

Is what you want but...

localtime = "08/04/2009 15:58:27" so you don't want / and : in your filename... so....

substring localtime 12 2 + substring localtime 15 2 would give you 1558 instead.....

EDIT: and you also need to get rid of the .max on your filename
maxfilepath + substring maxfilename 1 (maxfilename.count - 4) + substring localtime 12 2 + substring localtime 15 2 + ".tga"

Which will output you something like....

"C:\test\test1619.tga"

PiXeL_MoNKeY
04-08-2009, 03:04 PM
"localtime as string" should be (localtime as string). Anything inside " " is a string so by putting localtime as string in " " it will return "localtime as string". See the following example blue indicates the returned results to the maxscript listener."localtime as string"
"localtime as string"
(localtime as string)
"4/8/2009 10:03:28 AM"
rendOutputFilename = fullfilename + (localtime as string) + ".tga"-Eric

ZeBoxx2
04-08-2009, 03:41 PM
if you want to be a bit more flexible in the time stamp written out, use getLocalTime(). It's a bit more work to cast to a string to use, but well worth it.


tStamp = getLocalTime()
#(2009, 4, 3, 8, 17, 39, 52, 77)
tStampStr = stringStream ""
StringStream:""
format "%_%_%@%_%_%" tStamp[1] tStamp[2] tStamp[4] tStamp[5] tStamp[6] tStamp[7] to:tStampStr
OK
tStampStr as string
"2009_4_8@17_39_52"

LoneRobot
04-08-2009, 03:45 PM
a dotnet method also from the webulator -



-- overloaded tostring method

-- d: short date
-- D: long date
-- t: short time
-- T: long time
-- f: full Date/Time with short time
-- F: full Date/Time with long time
-- g: general Date/Time with short time
-- G: general Date/Time with long time
-- M or m: month day
-- R or r: RFC1123
-- s: sortable Date/Time that conforms to ISO 8601
-- u: universal sortable Date/Time
-- U: full Date/Time with long time. (This format is the same as F, but it uses universal GMT time.)
-- Y or y: year month

dateTimeInfo = (dotnetclass "system.datetime").Now
dateTimeInfo.ToString "t"

ZeBoxx2
04-08-2009, 04:32 PM
and here's one using filesystem timestamps

fName = ((sysInfo.tempdir) + (timestamp()) as string)
fHandle = createfile fName
close fHandle
getFileCreateDate fName


what... stop looking at me like that :curious:

thatoneguy
04-08-2009, 05:06 PM
I'm looking at you like that because you forgot to delete the file afterwords. :p

ZeBoxx2
04-08-2009, 05:19 PM
it's a temp file! clean-up.. psh.

JHN
04-08-2009, 08:45 PM
And more of the same, but utilizing a formatted print for a 2 digit hour notation, for better readability when used to output files.

t = getLocalTime()
#(2009, 4, 3, 8, 22, 42, 19, 62)
splitSign = "-"
"-"
renderDate = t[1] as string +"."+ t[2] as string +"."+ t[4] as string + splitSign + (formattedPrint t[5] format:".2d") +"." + (formattedPrint t[6] format:".2d") +"."+ t[7] as string
"2009.4.8-22.42.19"



-Johan

su37
04-10-2009, 02:14 AM
Thanks all ,Problems have been solved,Use ZeBoxx2's code:

(
try(makedir (pathConfig.convertPathToUnc (maxfilePath + "\\tga\\")))catch()
renderSceneDialog
tStamp = getLocalTime()
tStampStr = stringStream ""
format "%_%_%@%_%_%" tStamp[1] tStamp[2] tStamp[4] tStamp[5] tStamp[6] tStamp[7] to:tStampStr
tStampStr as string
time=tStampStr as string
renderWidth = 2500; renderHeight = 1875
fullfilename = maxFilePath + "\\tga\\" + (getFileNameFile maxfilename)
rendOutputFilename = fullfilename + time + ".tga" ------------------------- File format
rendSaveFile = true
max quick render
)

CGTalk Moderation
04-10-2009, 02:14 AM
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.