Skip to main content
December 16, 2025
Answered

After Effects script that Separates Dimensions and adds Expression to each

  • December 16, 2025
  • 1 reply
  • 207 views

Hi,

 

I would like to create a script for a UI Script panel with two separate buttons: one for X Position and one for Y Position.

The script should first separate the dimensions of the selected layer. Then, each button will apply the following expressions:

PosX button: [thisComp.width] * 1/2

PosY button: [thisComp.height] * 1/2

 

Correct answer Dan Ebberts

Ignoring your UI buttons for now, this example will set separate dimensions and add the expressions:

var layers = app.project.activeItem.selectedLayers;
if (layers.length > 0){
	var myLayer = layers[0];
	myLayer.property("Position").dimensionsSeparated = true;
	myLayer.property("Transform").property("X Position").expression = "thisComp.width/2";
	myLayer.property("Transform").property("Y Position").expression = "thisComp.height/2";
}else{
	alert("No layer selected.");
}

1 reply

December 16, 2025

I am having issues with the seperate dimesions function and how to get it tow work. Any help would be apricated. 

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
December 16, 2025

Ignoring your UI buttons for now, this example will set separate dimensions and add the expressions:

var layers = app.project.activeItem.selectedLayers;
if (layers.length > 0){
	var myLayer = layers[0];
	myLayer.property("Position").dimensionsSeparated = true;
	myLayer.property("Transform").property("X Position").expression = "thisComp.width/2";
	myLayer.property("Transform").property("Y Position").expression = "thisComp.height/2";
}else{
	alert("No layer selected.");
}
December 17, 2025

Thank you Dan - this now works and i have been able to get the script to work.