ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Using the timeToTimecode function in a script

COW Forums : Adobe After Effects Expressions

FAQ   •   VIEW ALL   •   ADD A NEW POST   •   PRINT
Respond to this post   •   Return to posts index   •   Read entire thread


James Malcolm
Using the timeToTimecode function in a script
on Sep 2, 2019 at 6:24:02 pm

I'm trying to adapt VideoCopilot's free 'Trim Compose' script, which precomposes multiple layers into trimmed comps.

Their original version appends the layer's in and out points in frames to the precomp title, and I'd like to append the layer's in point in 25fps timecode instead.

So I'm using the timeToTimecode expression, but I'm getting the error 'Function timeToTimecode is undefined' when I run the script.

The problem line in the below code is:

var layerTimecode = timeToTimecode(t=inPoint, timecodeBase=25, isDuration=false)

I've tested this exact code in an expression within After Effects and it works just fine, but it doesn't work when written into the script.

I also tried the code with 'thisLayer.timeToTimecode', but this doesn't work, I think because the line is nested in a for loop?

Any suggestions on how to adapt the code and get it working?

{
function precompTrim()
{

var curComp = app.project.activeItem;
if (!(curComp instanceof CompItem))
{
alert("Please select a composition.");
return;
}

var layers = curComp.selectedLayers;
if (layers.length == 0)
{
alert("Please select one or more layers.");
return;
}

app.beginUndoGroup("Precomp and Trim Layers");

var compFolder = prompt("Comp Folder Name", "Trimmed Comps");

var projItems = app.project.items;
for (var i=1; i<=projItems.length; i++)
if (projItems[i].typeName == "Folder" && projItems[i].name == compFolder)
{
compFolder = projItems[i];
break;
}

compFolder = app.project.items.addFolder(compFolder);

var offset = parseInt(prompt("Add Handles (frames)", "0"));
offset = offset * curComp.frameDuration;


for (var i=0; i>>
// >>>
var compName = layers[i].name;
var layerTimecode = timeToTimecode(t=inPoint, timecodeBase=25, isDuration=false)
var preCompName = compName + " " + layerTimecode;
// <>
// >>>
preComp.name = compName;
// <<<
// <<<
}

app.endUndoGroup();
}

precompTrim();
}


Posts IndexRead Thread 


Current Message Thread:





© 2019 CreativeCOW.net All Rights Reserved
[TOP]