Copy link to clipboard
Copied
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
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.");
}
Copy link to clipboard
Copied
I am having issues with the seperate dimesions function and how to get it tow work. Any help would be apricated.
Copy link to clipboard
Copied
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.");
}
Copy link to clipboard
Copied
Thank you Dan - this now works and i have been able to get the script to work.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more