-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstopMotion.jsx
174 lines (111 loc) · 3.77 KB
/
stopMotion.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
//quickStopMotion
//version 4.0
//2015 01.03 18:16
//copyright (c) songz meng
sM_Data = new Object();
sM_Data.scriptName = {
en: "quickStopMotion",
cn: "快速定格"
};
sM_Data.inPuText = {
en: "input time(second)",
cn: "输入时长(秒)"
};
sM_Data.exeCute = {
en: "execute",
cn: "执行"
};
sM_Data.noComp = {
en: "Please select a single composition in the Project panel, and try again.",
cn: "在项目面板选中或打开一个合成"
};
sM_Data.noLayer = {
en: "Please select a layer, and try again.",
cn: "请选中一个图层"
};
sM_Data.noText = {
en: "No text was input,try input numbers",
cn: "请输入数字再执行"
};
sM_Data.error = {
en: "error",
cn: "错误"
};
sM_Data.lastFrame = {
en: "manual precomp will be better at current time",
cn: "当前位置手动预合成更佳"
};
sM_Data.about = {
en: "thank you for using quicktext ae script. \n " + "\n" + "contact me: weibo.com/songz",
cn: "谢谢使用\n" + "\n" + "联系我 weibo.com/songz"
};
win = new Window('palette', sM_localize(sM_Data.scriptName));
wP = win.add("panel", [0, 0, 225, 100], sM_localize(sM_Data.inPuText));
wP.eT = wP.add("edittext", [15, 15, 150, 35]);
wP.eC = wP.add("button", [15, 45, 205, 75], sM_localize(sM_Data.exeCute));
wP.qU = wP.add("button", [180, 15, 205, 35], '?');
win.show();
function sM_validNum() {
var enteredValue = this.text;
if (isNaN(enteredValue) || (enteredValue <= 0)) {
this.text = "1";
};
};
function sM_localize(Var) {
if (app.isoLanguage === "zh_CN") {
return Var["cn"];
} else {
return Var["en"];
}
};
wP.eT.onChange = sM_validNum;
wP.qU.onClick = function() {
alert(sM_localize(sM_Data.about), sM_localize(sM_Data.scriptName))
};
wP.eC.onClick = function() {
app.beginUndoGroup(sM_localize(sM_Data.scriptName));
aI = app.project.activeItem;
if (!(aI instanceof CompItem)) {
alert(sM_localize(sM_Data.noComp), sM_localize(sM_Data.error));
return;
}
if (aI.selectedLayers.length == 0) {
alert(sM_localize(sM_Data.noLayer), sM_localize(sM_Data.error));
return;
}
if (wP.eT.text == "") {
alert(sM_localize(sM_Data.noText), sM_localize(sM_Data.error));
return;
}
sL = aI.selectedLayers;
if (aI.time == sL[0].outPoint-1/aI.frameRate ) {
alert(sM_localize(sM_Data.lastFrame), sM_localize(sM_Data.error));
return;
}
sLAr = new Array();
sLAr[0] = sL[0].index;
iP = sL[0].inPoint;
aI.layers.precompose(sLAr, sL[0].name, true);
sL = aI.selectedLayers;
sL[0].source.displayStartTime = sL[0].source.layer(1).inPoint;
sL[0].source.layer(1).startTime -= sL[0].source.layer(1).inPoint;
sL[0].source.duration = sL[0].source.layer(1).outPoint - sL[0].source.layer(1).inPoint;
sL[0].startTime = iP;
if ((sL[0].outPoint + parseFloat(wP.eT.text)) > aI.duration) {
aI.duration = sL[0].outPoint + parseFloat(wP.eT.text);
};
sL[0].timeRemapEnabled = true;
sL[0].timeRemap.setValueAtTime(sL[0].time, sL[0].timeRemap.value);
var i;
if (sL[0].timeRemap.numKeys == 3) {
i = 3;
} else {
i = 2;
}
oPkeyTime = sL[0].timeRemap.keyTime(i);
sL[0].timeRemap.setValueAtTime(oPkeyTime + parseFloat(wP.eT.text), sL[0].timeRemap.keyValue(i));
sL[0].timeRemap.removeKey(i);
sL[0].timeRemap.setValueAtTime(aI.time + parseFloat(wP.eT.text), sL[0].timeRemap.value);
sL[0].outPoint = sL[0].timeRemap.keyTime(sL[0].timeRemap.numKeys);
app.endUndoGroup();
};