Page 1 of 2

Pre-comp to layer duration

Posted: June 26th, 2004, 10:32 am
by Dan Ebberts
Hi everybody,

Brian Maffitt came up with a clever idea for a script that precomps selected layers with the "Move all attributes..." option and trims the precomp to the duration of the layers inside. I've got it posted (along with an explanation of how it works) here: ... r-dur.html

You should be able to copy and paste it into a text editor directly from the web page. Please let me know if you have any problems with it.


Posted: July 27th, 2005, 3:09 pm
by Disciple
I use this script a lot, and one thing bugs me with it is that it doesen't give you a chance to rename your pre-comp, so you end up with standard names.
Can it be modified to give the user a dialog to pick a name?


Posted: July 27th, 2005, 4:55 pm
by vidpat
When I started using this script, I added a dialog for my own use. See if this works for you: ... ration.jsx


Posted: July 28th, 2005, 1:00 am
by Disciple
Hey Peter
Looks pretty cool, but isn't there an attached script?

This looks very cool though


Posted: July 28th, 2005, 3:27 am
by vidpat
I forgot to mention: the script depends on UILayout_13.jsx which is a version of the layout manager I wrote. See to download it.

I too use this script frequently. So, while I'm at it, many thanks to Brian, Keiko, and Dan for conceiving and implementing the original script.


Posted: July 28th, 2005, 4:16 am
by Disciple
Thanks Peter

However I run into an error message when I try to run to run the script :
"Unable to execture script at line 336 UILM_DISABLE_STRING_DISPLAY_WIDTH_GUESS is undefined"

Any idea of what this is?


Posted: July 28th, 2005, 1:23 pm
by vidpat
That variable should be defined in UILayout_13.jsx. I'm not getting the error here. Hmm. Try downloading UILayout_13 again on the off chance that it was corrupted during transfer. If you're still having the problem, I'll keep investigating.


Posted: July 28th, 2005, 5:24 pm
by Disciple
Hmm, still doesen't work.
I put the UILayout.13_jsx in a (lib) folder inside the scripts folder.
Anything wrong there?


Posted: July 28th, 2005, 6:50 pm
by vidpat
I'm stumped. UILayout_13.jsx should be in the subdirectory (lib) of the directory in which PrecompToDuration.jsx is located.

The fact that you are getting an error about UILM_DISABLE_STRING_DISPLAY_WIDTH_GUESS means that it is finding and loading UILayout_13.jsx. Why it isn't defined by the time the script starts laying out the components is baffling.

You could change the dialog code in PrecompToDuration.jsx so that it doesn't use the layout manager and then remove the include.

I'll keep looking to see what the problem could be.


Posted: August 9th, 2005, 9:48 pm
by vidpat
Have you had any luck getting PrecompToDuration to run? I've been looking through UILayout and haven't come across anything that could cause the problem.

Posted: August 14th, 2005, 5:28 pm
by Disciple
Nope. I've been on vacation since I finished the latest project I was working on, so I didn't investigate much more. I'll try on a different system hopefully this week.


Posted: August 23rd, 2005, 1:06 pm
by Disciple

Sorry for taking so long to get back to you on this. I just tried the script on another system and it works beautifully! Thanks so much for this, it is really a really perfect addition to this amazing script.


Install Guide That Works with vidpat:s UI dialogues

Posted: January 7th, 2008, 8:10 am
by sundstedt
Download the files from links above, here is what I did and I can confirm it works with vidpat:s added dialogue:

1. Install UILayout_13.jsx to your Script Directory (i.e. C:\Program Files\Adobe\Adobe After Effects CS3\Support Files\Scripts\ScriptUI Panels)

2. Install UIChooser.jsx into the same dir.

3. Install PrecompToDuration.jsx into the same dir.

4. Change line 24 in the PreCompToDuration to:

includeScripts = ["UILayout_13.jsx"];

(Or make a folder "lib" if you'd like, but I just wanted a quick fix).


Re: Pre-comp to layer duration

Posted: June 12th, 2008, 3:57 pm
by ChrisZwar

This was the first script I ever used, and I've tweaked it slightly to suit my workflow.

I've adjusted it so that when you precomp a layer (or several), the layer begins at the start of the new precomp, and the precomp begins at the in-point of the original layer. This is different from the original script, where the layer in-point is unchanged and the precomp is trimmed to that point rather than actually being moved there.

I use this script alongside the Magnum edit detector when I am cutting up exported edits into individual compositions for effects and graphics work (one day I will get Automatic Duck...) - hence I've also tweaked the naming convention to reflect the layer number.

When an edit has been locked off and I am working on individual shots in After Effects, I prefer to have each shot in its own composition and starting at the beginning of that composition. This is especially useful if you are working with 3D artists who like working with frame numbers rather than timecode, and render out image sequences beginning with 0.

Hope you find it a useful variation, thanks again to Dan for the original!

-Chris ... ration.jsx

Re: Pre-comp to layer duration

Posted: August 7th, 2009, 11:39 am
by megapuppy
I've just created an alternate version of this script, which is designed to speed up the process of setting up a edit-style project in AE (for example, a split timeline created using Magnum or Automatic Duck).

It's designed to be used on multiple layers, but instead of merging them into one combined comp, it precomps them individually - effectively running an individual version of the original script on every layer selected. This is really handy for setting up comps initially (and creating logically named comps like "Shot_001" etc). The new comps have a name defined by the user + a comp number (padded to 3 digits, which should be OK for most projects).

Anyway, it all seems to work OK, I'm using it on a job right now. Thought I'd share it with the community, spread the love ;)

link: ... iLayer.jsx

ps. One caveat - the order you select your footage is important. If you just do "Select All" then run the script it will create the comps from the top downwards. So shift + select from the bottom upwards if that's the order you need!