Copy link to clipboard
Copied
I want to extract frame count using JSX script?
I have used following code. But it seems not sharp as expected (In case of decimal point of seconds it seems not good)
function getTimelineLength() {
var ref = new ActionReference();
ref.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('duration'));
ref.putClass(stringIDToTypeID('timeline'));
var desc = new ActionDescriptor();
desc.putReference(charIDToTypeID('null'), ref);
var TC = executeAction(charIDToTypeID('getd'), desc, DialogModes.NO);
TC = TC.getObjectValue(stringIDToTypeID('duration'));
var M = 0;
try { M = TC.getInteger(stringIDToTypeID('minutes')); } catch (e) { }
var S = 0;
try { S = TC.getInteger(stringIDToTypeID('seconds')); } catch (e) { }
var F = TC.getInteger(stringIDToTypeID('frame'));
var FR = TC.getInteger(stringIDToTypeID('frameRate'));
var A = new Array();
A.push([[M], [S], [F], [FR]]);
return A;
}
//option 1
var frameCount = timeLineInfo[0][2] ( But this returns "0" value with newly opened document)
//option 2
var timeLineInfo = getTimelineLength()
var frameCount = timeLineInfo[0][1] * timeLineInfo[0][3] ( This is not returns correct value with decimal value of seconds )
Anyone have a better solution?
Copy link to clipboard
Copied
var r = new ActionReference();
r.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('frameCount'));
r.putClass(stringIDToTypeID('timeline'));
var ret = executeActionGet(r);
alert( ret.getInteger(stringIDToTypeID('frameCount')) );
//
Copy link to clipboard
Copied
And again. Thanks alot r-bin.
Copy link to clipboard
Copied
You also can get next properties of tilmeline
time
currentFrame
documentTimelineSettings
duration
enabled
frameCount
frameRate
hasMotion
workInTime
workOutTime
Copy link to clipboard
Copied
Thanks, r-bin. Very helpful.
Is there any documentation regarding these details?
I have tried using ScriptListener, but I could found a way to access and identify property details using output scripts.
Copy link to clipboard
Copied
This is my personal hacking experience. )
You can download Adobe Photoshop SDK and find in the file "PITerminology.h" the names of all the strings and chars for stringIDToTypeID or charIDToTypeID functions. Then you can write a script that checks the availability of the desired property for the object or class scrolling through all the strings. If successful, you can get the type of property and its data.
Sorry for the bad english.
Copy link to clipboard
Copied
Understood very well.
I observed several scripts, But still couldn't understand the pattern of coding.
If you have time, Could you please explain how did you construct below two sample scripts.
var r = new ActionReference();
r.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('frameCount'));
r.putClass(stringIDToTypeID('timeline'));
var ret = executeActionGet(r);
alert( ret.getInteger(stringIDToTypeID('frameCount')) );
-------------------------------------------------------------------------
function next_key_frame()
{
var d1 = new ActionDescriptor();
var d2 = new ActionDescriptor();
d2.putEnumerated( stringIDToTypeID( "trackID" ), stringIDToTypeID( "stdTrackID" ), stringIDToTypeID( "sheetPositionTrack" ) );
d1.putObject( stringIDToTypeID( "trackID" ), stringIDToTypeID( "animationTrack" ), d2 );
executeAction( stringIDToTypeID( "nextKeyframe" ), d1, DialogModes.NO );
}
Copy link to clipboard
Copied
ok.
The second script I got using ScriptListener.
And the first one I got using this script to get a list of available properties.
Copy link to clipboard
Copied
WOW.
Thanks a lot, r-bin. Really appreciate.
Copy link to clipboard
Copied
))
There is an extended version of the script where you can see the values of simple property types or browse the properties of complex objects like OBJECT, LIST, REFERENCE, RAWTYPE, etc. to any depth.
But it only works on CS6 since on CC broke multi-column listboxies.
I can post link later if necessary.
Copy link to clipboard
Copied
Yes, Please post it r-bin. I will be very useful.
Copy link to clipboard
Copied
ok, keep it
Copy link to clipboard
Copied
Hello r-bin,
Unfortunately, the link doesn't work now. Could you please update it. I am really eager to know how did you get those properties of the timeline, what was the process. Thank you.
Copy link to clipboard
Copied
Probably that's the same that was in zip file: get_props