ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Shift-Parent Script: Modification-Advice needed

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Michael Schneider
Shift-Parent Script: Modification-Advice needed
on Nov 29, 2019 at 11:57:32 pm
Last Edited By Michael Schneider on Nov 30, 2019 at 12:28:12 am

I need to Shift-parent nearly 100 images to the same number of shape layers, so that the images adopt the position values of the shape layers. I found this great script by Nik Ska: https://github.com/ae-scripting/scripting-snippets/blob/master/batchParent.... that basically does what I need, but without the Shift-part..

Does anyone know how to adapt the script for Shift-parenting needs?

Thanks in advance and best wishes from Germany,
Michael

//Batch parent layers
//1. select the batch you want to set parents to
//2. select the batch you want to parentthe first batch to

//order matters

//0.1 - initial release

//CC-BY-SA, Nik Ska, 2013


var nsBatchParent = this;
this.version = 0.1;
this.scriptTitle = "Batch Parent";

nsBatchParent.run = function(){
this.buildGUI(this);
}

nsBatchParent.thisBatch = [];
nsBatchParent.thatBatch = [];

nsBatchParent.buildGUI = function(thisObj){
thisObj.w = (thisObj instanceof Panel) ? thisObj : new Window("palette", thisObj.scriptTitle, undefined, {resizeable:true});
thisObj.w.alignChildren = ['left', 'top']

var l1 = thisObj.w.add("group{orientation:'row', alignChildren: ['left', 'top']}");
l1.add("staticText", undefined, "Parent");
l1.margins = [0,0,0,0];
var thisBttn = l1.add("button", undefined, "this");
thisBttn.size = [40, 20];

var l2 = thisObj.w.add("group{orientation:'row', alignChildren: ['left', 'top']}");
var toTxt = l2.add("staticText", undefined, " to");
toTxt.size = [33,20];
l2.margins = [0,0,0,0];
var thatBttn = l2.add("button", undefined, "that");
thatBttn.size = [40, 20];

thisBttn.onClick = function(){
thisObj.getThis(thisObj);
}

thatBttn.onClick = function(){
thisObj.getThat(thisObj);
}

if (thisObj.w instanceof Window){
thisObj.w.center();
thisObj.w.show();
}
else thisObj.w.layout.layout(true);
}

nsBatchParent.getThis = function(thisObj){
var activeComp = app.project.activeItem;
if(activeComp && activeComp instanceof CompItem){
if(activeComp.selectedLayers.length){
thisObj.thisBatch = activeComp.selectedLayers;
}
else alert("Select at least one layer")
}
}

nsBatchParent.getThat = function(thisObj){
var activeComp = app.project.activeItem;
if(activeComp && activeComp instanceof CompItem){
if(activeComp.selectedLayers && activeComp.selectedLayers.length === thisObj.thisBatch.length){
thisObj.thatBatch = activeComp.selectedLayers;
thisObj.parentShit(thisObj);
}
else alert("Select the same amount of layers: " + thisObj.thatBatch.length)
}
}

nsBatchParent.parentShit = function(thisObj){
app.beginUndoGroup("Batch Parenting");
for(var i = 0; i &lt; thisObj.thisBatch.length; i++){
if(thisObj.thisBatch[i]!=thisObj.thatBatch[i]){
thisObj.thisBatch[i].parent = thisObj.thatBatch[i];
}
}
app.endUndoGroup();

}

nsBatchParent.run();


Return to posts index

Michael Schneider
Re: Shift-Parent Script: Modification-Advice needed
on Dec 1, 2019 at 10:24:05 am

For all of you that might haven't learned about Shift-Parenting yet or maybe forgot about it, here's a great explainer by ukramedia:





It really can be incredibly useful in certain scenarios.



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]