Skip to main content
Inspiring
August 3, 2022
Answered

How I can change part of my expression using JavaScript ?

  • August 3, 2022
  • 1 reply
  • 392 views

When I extracting Duik controllers to the other composition. it creates an expressions on controllers into composition with all my rigged character, and thats some issues when After Effect can lose name of composition in expression when I rename my comp, thats sample:

//Duik.link
var link = comp("Comp 1").layer("B_HEAD").transform.position;
var timeLayer = comp("Comp 1").layer("Boss_1");
var timeOffset = timeLayer.startTime;
link.valueAtTime(time + timeOffset);

If I want to rename my comp, AE show an error thats he can`t find composition and expression is doesnt work

I want to write a Script that can help me change this part of my expression and place the correct composition name 

This topic has been closed for replies.
Correct answer Dan Ebberts

Say you chage the name of "Comp 1" to "New Comp Name". Your script might be as simple as this:

 

 

app.project.autoFixExpressions("Comp 1", "New Comp Name");

 

 

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
August 3, 2022

Say you chage the name of "Comp 1" to "New Comp Name". Your script might be as simple as this:

 

 

app.project.autoFixExpressions("Comp 1", "New Comp Name");

 

 

MoistoffAuthor
Inspiring
August 4, 2022

It works! Thank you! 
But can I using this method automatically found where Script should changing text? I found this line

app.project.activeItem.propertySpec.expression

Is this what I want? Cuz I cant understand how this line works 😞 

Dan Ebberts
Community Expert
Community Expert
August 4, 2022

I'm not sure what you're asking, but I don't think you'd use .propertySpec, which is just shorthand notation for the the actual path to a property, like .property("Position"), without specifying a layer.