Copy link to clipboard
Copied
Hello dear AE Scripting Forum,
I m trying to build a little script that helps me with precomposing. Everything is working fine so far but I can't find a way to convert on the property Time Remap all Keyframes to HoldKeyframes. I've tried it like this:
var inType = KeyframeInterpolationType.HOLD;
var outType = KeyframeInterpolationType.HOLD;
prompt(preCompLayer.property("Time Remap"));
for (var i = 0; i < preCompLayer.property("Zeitverzerrung").numKeys.length; i++){
preCompLayer.property("Zeitverzerrung").numKeys.setInterpolationTypeAtKey(keyIndex, inType, outType);
}
And another question is:
Are the property names localized? In my case. Do i need to use "Time Remap" insted of "Zeitverzerrung"?
Best regards
fabiantheblind
That looks pretty close. I haven't actually checked it works, but something like this:
var holdInt = KeyframeInterpolationType.HOLD;
var property = preCompLayer.property("ADBE Time Remapping");
for (var i = 1; i <= property.numKeys; i++){
property.setInterpolationTypeAtKey(i, holdInt, holdInt);
}
Use the property matchNames (read using property.matchName) to avoid localization issues, in this case "ADBE Time Remapping".
Copy link to clipboard
Copied
That looks pretty close. I haven't actually checked it works, but something like this:
var holdInt = KeyframeInterpolationType.HOLD;
var property = preCompLayer.property("ADBE Time Remapping");
for (var i = 1; i <= property.numKeys; i++){
property.setInterpolationTypeAtKey(i, holdInt, holdInt);
}
Use the property matchNames (read using property.matchName) to avoid localization issues, in this case "ADBE Time Remapping".
Copy link to clipboard
Copied
Great its working! Thnx a lot.
Here the full script:
// written by fabiantheblind
// based on Andrew Reynolds Sequencer.jsx http://www.videocopilot.net/
// based on Dan Ebberts preCompToLayerDur.jsx http://www.motionscript.com
// with a little help by Paul Tuersley http://forums.adobe.com/people/Paul%20Tuersley
function SequenceAndPrecompose()
{
app.beginUndoGroup("Pre-Compose to Layer Duration");
var curComp = app.project.activeItem;
if (!curComp || !(curComp instanceof CompItem))
{
alert("Please select a Composition.");
return;
}
var offsetFrames = 1;//parseInt(prompt("Number of frames to offset", "1"));
for (var layerId = 0; layerId < curComp.selectedLayers.length; layerId++)
{
var layer = curComp.selectedLayers[layerId];
layer.startTime = layerId * offsetFrames * curComp.frameDuration;
layer.outPoint = layer.inPoint +1*curComp.frameDuration;
}
var myLayers = curComp.selectedLayers;
var newInPoint = myLayers[0].inPoint;
var newOutPoint = myLayers[0].outPoint;
var newCompName = "comp_";
var layerName = myLayers[0].name;
if(layerName.length > 26) {
layerName = layerName.substring(0, 26);
}
newCompName += layerName;
// "precompose" expects an array of layer indices
var layerIndices = new Array();
for (var i = 0; i < myLayers.length; i++) {
layerIndices[layerIndices.length] = myLayers.index;
// make sure new comp in point is in point of earliest layer
// and new comp out point is out point of latest layer
if (myLayers.inPoint < newInPoint) newInPoint = myLayers.inPoint;
if (myLayers.outPoint > newOutPoint) newOutPoint = myLayers.outPoint;
}
// create the new comp
var newComp = curComp.layers.precompose(layerIndices, newCompName, true );
// set in and out points of new comp
var preCompLayer = curComp.selectedLayers[0];
preCompLayer.inPoint = newInPoint;
preCompLayer.outPoint = newOutPoint;
preCompLayer.timeRemapEnabled = true;
var holdInt = KeyframeInterpolationType.HOLD;
var property = preCompLayer.property("ADBE Time Remapping");
for (var i = 1; i <= property.numKeys; i++){
property.setInterpolationTypeAtKey(i, holdInt, holdInt);
}
app.endUndoGroup();
}
SequenceAndPrecompose();