Copy link to clipboard
Copied
Hi all.
The project (Test.aep) contains one composition with one layer.
This layer has a mask in add mode that selects a small part of the layer.
drawing t1.png
If you do the following in manual mode:
1. Using the Anchor Point layer parameter, place the area with the mask in the center of the composition.
figure t2.png
2. Resize the composition so that it contains only the area selected by the mask.
Composition menu / Composition parameters .... pictures t3.png, t4.png
Then we get the state of the scene> t5.png
I assumed that the code below will repeat what was done in manual mode.
app.project.activeItem.layer(1).selected = true;
app.project.activeItem.layer(1).transform.anchorPoint.setValue([1239.5, 368.0]);
app.project.activeItem.width = 130
app.project.activeItem.height = 135
But scene state > t6.png
Is there a way, using a script, to come to the state of the scene t5.png
The reason is, if you look in the advance tab of the composition settings, you'll see you can choose where it resizes the comp around. It defaults to center. As the co-ordinate system is based on zero at the top left, it then has to adjust all the position values so it is centered in the resized comp.
Scripting doesn't do that automatically, you're literally just telling it to change the comp size, so all the position values stay unchanged and relative to the original comp size. So you need to o
...Copy link to clipboard
Copied
The reason is, if you look in the advance tab of the composition settings, you'll see you can choose where it resizes the comp around. It defaults to center. As the co-ordinate system is based on zero at the top left, it then has to adjust all the position values so it is centered in the resized comp.
Scripting doesn't do that automatically, you're literally just telling it to change the comp size, so all the position values stay unchanged and relative to the original comp size. So you need to offset the Position values by half the difference between the original comp size and the new comp size.
You started with a 1925x1080 comp with a Position value of 962.5, 540.
You ended up with a 130x135 comp with a Position value of 65,67.5
Half the difference for comp size is:
x: 1925-130=1795 / 2 = 897.5
y: 1080-135=945 / 2 = 472.5
So you need to offset the Position:
x: 962.5-897.5 = 65
y: 540-472.5 = 67.5
Find more inspiration, events, and resources on the new Adobe Community
Explore Now