-
Notifications
You must be signed in to change notification settings - Fork 1
/
LayerNullIT.jsx
54 lines (34 loc) · 1.44 KB
/
LayerNullIT.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Name: LayerNullIT
// Author: keerah.com
// Description: this is an After Effects script that creates nulls
// for each of currently selected layers at their position (copying rotation and scale)
// check if there's a project and there's a comp
if ((app.project.activeItem != null) && (app.project.activeItem instanceof CompItem)) {
var myComp = app.project.activeItem;
var sLayers = myComp.selectedLayers;
// check if there's any layers selected
if (sLayers.length > 0) {
// let's care of undoing things
app.beginUndoGroup("Add nulls for layers");
// lets'go through the selection
for (var i = 0; i < sLayers.length; i++) {
// create null
var newLayer = myComp.layers.addNull();
// set the null's position
newLayer.property("Position").setValue(sLayers[i].transform.position.value);
// set the null's rotation
newLayer.property("Rotation").setValue(sLayers[i].transform.rotation.value);
// set the null's scale
newLayer.property("Scale").setValue(sLayers[i].transform.scale.value);
// set the null's opacity
newLayer.property("Opacity").setValue(0);
// move null before the layer
newLayer.moveBefore(sLayers[i])
}
app.endUndoGroup()
} else {
alert("Please select one or a few layers")
}
} else {
alert("Please select one or a few layers in any composition")
}