Skip to main content
Dec 16, 2025 4:05 AM UTC
Answered

After Effects script that Separates Dimensions and adds Expression to each

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

 

Dan Ebberts
Dan EbbertsCorrect answer
Community Expert
Dec 16, 2025 4:54 PM UTC

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.");
}

3 replies

Dec 16, 2025 5:01 AM UTC

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

Translate
Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
Dec 16, 2025 4:54 PM UTC

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.");
}
Translate
Dec 17, 2025 12:39 AM UTC

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

Translate