PDA

View Full Version : TimeMarkerGN



faulknermano
07-31-2005, 10:21 AM
dont know if anything like this already exists (wont be surprised if it did). i thought of writing this up a year ago but never got around to doing it except now. basically, it's an animation stopwatch that allows you to mark different times in one pass.

caution: to increase actual time accuracy, run this script on an empty scene so as to not to slow down the script from executing at the proper times.



//code follows
@name TimeMarkerGN
@warnings 0
@asyncspawn
@define CF_FRAMEINTEGER 1
@define CF_FRAMEDECIMAL 2
marker = false;
elapsedTime = -.03;
mai = 0;
markerArray;
start = false;

generic
{
openAfter = integer(recall("openAfter",1));
counterFormat = integer(recall("counterFormat",1));
myFps = integer(recall("myFps",4));
reqbegin("Time Marker : faulknermano 2005");

// c1 = ctlbutton("Mark",100,"markNow");
c0 = ctlchoice("FPS",myFps,@"15","24","29.97","30"@);
c1 = ctlcheckbox("Open text file after marking",openAfter);
c2 = ctlchoice("Counter format",counterFormat,@"Frame Integer","Frame Decimal"@);
d1 = ctltext("Press SPACEBAR to mark time.","Press ESC or ENTER when done.");

reqpost("checkMarker",30);

uf = getvalue(c0);

if(myFps == 1)
uf = 15;

if(myFps == 2)
uf = 24;

if(myFps == 3)
uf = 29.97;

if(myFps == 4)
uf = 30;

openAfter = getvalue(c1);
counterFormat = getvalue(c2);

store("myFps",myFps);
store("openAfter",openAfter);

fn = getfile("Save Marked Times .txt");

if(!fn)
error("User aborted save.");

f = File(fn,"w+");



if(!f)
error("Error opening file for writing.");
f.writeln("Mark #\tFrame");
for(i=1;i<=markerArray.size();i++)
{

if(counterFormat == CF_FRAMEINTEGER)
v = convertFrameInteger(markerArray[i],uf);
if(counterFormat == CF_FRAMEDECIMAL)
v = convertFrameDecimal(markerArray[i],uf);

str = string(i,"\t",v);
f.writeln(str);
}
if(openAfter)
{
str = string("notepad \"",fn,"\"");
spawn(str);
}

}

convertFrameInteger: ma, uf
{
v = ma * uf;
v = round(v,0);
return(v);
}

convertFrameDecimal: ma, uf
{
return(ma * uf);
}
checkMarker
{
if(start == false)
return;
elapsedTime = elapsedTime + .03;
if(marker == true)
{
marker = false;
markerArray[++mai] = elapsedTime;
}
}
markNow
{
start = true;
marker = true;
}

reqkeyboard: key
{
if(key == 32) // space
{
markNow();
}

}

// end script




best,


lernie.