Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

After Effects script that Separates Dimensions and adds Expression to each

New Here ,
Dec 15, 2025 Dec 15, 2025

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

 

TOPICS
Expressions , Scripting
189
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 16, 2025 Dec 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.");
}
Translate
New Here ,
Dec 15, 2025 Dec 15, 2025

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 16, 2025 Dec 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.");
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 16, 2025 Dec 16, 2025
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines