Don, check this out, it should be it.
The only think to keep in mind is that is you make selection not in an incremental order (lets say pick 1,3,2,5 layers for selection A), it will be applied in the same order for your parenting. Other than that, it should be it.
Cheers!
var w = new Window ("palette", "Link");
w.add("button", undefined,"Selection 1",{name:"ok"}).onClick = function(){ selectLayersA(); }
w.add("button", undefined,"Link To Selection 2",{name:"ok"}).onClick = function(){ selectLayersBLink(); }
w.show();
var selectionArray = new Array();
function selectLayersA(){
var activeComp = app.project.activeItem;
var selectedLayersA = new Array();
selectedLayersA = activeComp.selectedLayers;
for (var b = 0; b < selectedLayersA.length; b++){
selectionArray[selectionArray.length] = selectedLayersA[b];
}
}
function selectLayersBLink(){
app.beginUndoGroup("Link to comps");
var activeComp = app.project.activeItem;
var selectedLayersB = new Array();
selectedLayersB = activeComp.selectedLayers;
for (var i = 0; i < selectionArray.length; i++){
if (selectedLayersB[i] != null){
layerA = selectionArray[i];
layerB = selectedLayersB[i];
layerB.parent = layerA;
}
}
selectionArray = []
app.endUndoGroup();
}
Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer – Dynamic Text Boxes Template with a Live Preview
Social Media Profiles