-
scripting: replaceSource for null layer
Hi,
I’m trying to write a simple script that will do batch source replacing — specifically to attach footage to C4D particles exported as AE nulls.An example project file (AE 2015) and script can be downoaded here: 10016_replacesourceofnull.zip
The script is also posted below.
(To use the script, first select the project item to be swapped in and then the null layer.)The problem: running replaceSource() on a null layer results in an “invisible” layer — the swap appears to be successful in the timeline view (and I make sure that the layer’s opacity is at 100%) but it is not visible in the Composition Viewer, though the layer’s bounds do appear to be updated.
Replacing the null’s source manually (using opt+drag or the keyboard shortcut) works fine — and I’m confused why there’s a difference between that and replaceSource()
Maybe I’m overlooking something obvious? Any Ideas?
Thanks,
–Ross*using AE 2015
app.beginUndoGroup("Source Swap");app.activeViewer.setActive();
var theSelectedLayers = app.project.activeItem.selectedLayers;
var theSelectedItemsToSwapIn = app.project.selection;if(theSelectedLayers.length > 0 && theSelectedItemsToSwapIn.length > 0){
for(var i = 0; i < theSelectedLayers.length; i++){
var j = i % theSelectedItemsToSwapIn.length;
theSelectedLayers[i].replaceSource(theSelectedItemsToSwapIn[j], true);
}
} else {
alert("Error: Please select 1 or more layers and 1 or more items in the Project window");
}app.endUndoGroup();
Sorry, there were no replies found.