Skip to main content
DiRiver
Participant
June 18, 2024
Answered

How to change color to shape from other composition?

  • June 18, 2024
  • 1 reply
  • 155 views

Hey all,

I have a compositions named from P1 to P10 (I'll call them "Parent" compositions) consisting of shape "RandShape" and  composition named "C" + number according to the composition in which it is located (I'll call them "Child" compositions). Compositions "Child" consisting of shape "ParShape". I need to change ParShape's color to RandShape's color. RandShape's color generates randomly. 

Any ideas how to do it with script?

This topic has been closed for replies.
Correct answer DiRiver

I did it!

var child = app.project.item(1);
var parent = app.project.item(12);

for(i = 1; i <= placeholder.numItems; i++){
  compId = comps.item(i);
  var rgbValue = compId.layer("RandShape").content("Ellipse 5").content("Fill 1").color.value;
  child.item(i).layer("ParShape").content("Rectangle 1").content("Fill 1").color.setValue(rgbValue);
}

 

1 reply

DiRiver
DiRiverAuthorCorrect answer
Participant
June 18, 2024

I did it!

var child = app.project.item(1);
var parent = app.project.item(12);

for(i = 1; i <= placeholder.numItems; i++){
  compId = comps.item(i);
  var rgbValue = compId.layer("RandShape").content("Ellipse 5").content("Fill 1").color.value;
  child.item(i).layer("ParShape").content("Rectangle 1").content("Fill 1").color.setValue(rgbValue);
}