Skip to main content
Participant
February 1, 2024
Question

Parenting by name

  • February 1, 2024
  • 1 reply
  • 142 views

Hi everyone

 

I am just wondering if there is a way to automatically parenting compositions to nulls just by the same name.

 

exemple:

 

Comp name: TEST01

Null name: TEST01

 

Is there any expression for this? or is this even possible?

This topic has been closed for replies.

1 reply

Legend
February 1, 2024

Not using an expression but a script:

 

var proj = app.project;
var thisComp = proj.activeItem;

app.beginUndoGroup("Undo");
for (var i = 1; i <= thisComp.numLayers; i++) {
  if (thisComp.layer(i).source instanceof CompItem) {
    for (var j = 1; j < thisComp.numLayers; j++) {
      if (thisComp.layer(j).nullLayer && thisComp.layer(j).name == thisComp.layer(i).name) {
        thisComp.layer(i).parent = thisComp.layer(j)
      }
    }
  }
}
app.endUndoGroup();