-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource1.jsx
More file actions
334 lines (277 loc) · 12.6 KB
/
Copy pathSource1.jsx
File metadata and controls
334 lines (277 loc) · 12.6 KB
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
// Function to create UI (dockable panel or floating window)
function createUI(thisObj) {
var mainWindow;
// Check if the script is being run from the Script Editor or as a dockable panel
if (thisObj instanceof Panel) {
mainWindow = thisObj;
} else {
mainWindow = new Window("palette", "WorkFlow", undefined, {resizeable: true});
mainWindow.orientation = "column"; // Set orientation to column for main window
}
// Create the first row (single column)
var row1 = mainWindow.add("group");
row1.orientation = "row"; // Set orientation to row
// Add buttons to the first row
var solidButton = row1.add("button", undefined, "Solid");
solidButton.size = [50, 25]; // Adjust button size as needed
solidButton.onClick = function() {
var project = app.project;
// Check if there is an active project
if (project === null) {
alert("No project open. Please open a project and try again.");
return;
}
// Get the active composition
var comp = project.activeItem;
// Check if the active item is a composition
if (comp === null || !(comp instanceof CompItem)) {
alert("No active composition. Please select an active composition and try again.");
return;
}
// Check if there are selected layers
if (comp.selectedLayers.length === 0) {
alert("No layers selected. Please select a layer and try again.");
return;
}
// Get the first selected layer
var selectedLayer = comp.selectedLayers[0];
// Get the start time and duration of the selected layer
var startTime = selectedLayer.inPoint;
var duration = selectedLayer.outPoint - selectedLayer.inPoint;
var brush = mainWindow.graphics.newBrush(mainWindow.graphics.BrushType.SOLID_COLOR, [9/255, 24/255, 28/255]);
// Add a solid layer to the composition
var solidLayer = comp.layers.addSolid([1, 0, 0], "Red Solid", comp.width, comp.height, comp.pixelAspect, comp.duration);
solidLayer.startTime = startTime;
solidLayer.inPoint = startTime;
solidLayer.outPoint = startTime + duration;
solidLayer.moveBefore(selectedLayer);
};
var adjustmentButton = row1.add("button", undefined, "Adj");
adjustmentButton.size = [50, 25]; // Adjust button size as needed
var brush = mainWindow.graphics.newBrush(mainWindow.graphics.BrushType.SOLID_COLOR, [9/255, 24/255, 28/255]);
mainWindow.graphics.backgroundColor = brush;
adjustmentButton.onClick = function() {
var project = app.project;
// Check if there is an active project
if (project === null) {
alert("No project open. Please open a project and try again.");
return;
}
// Get the active composition
var comp = project.activeItem;
// Check if the active item is a composition
if (comp === null || !(comp instanceof CompItem)) {
alert("No active composition. Please select an active composition and try again.");
return;
}
// Check if there are selected layers
if (comp.selectedLayers.length === 0) {
alert("No layers selected. Please select a layer and try again.");
return;
}
// Get the first selected layer
var selectedLayer = comp.selectedLayers[0];
// Get the start time and duration of the selected layer
var startTime = selectedLayer.inPoint;
var duration = selectedLayer.outPoint - selectedLayer.inPoint;
// Add an adjustment layer to the composition
var adjustmentLayer = comp.layers.addSolid([1, 1, 1], "Adjustment Layer", comp.width, comp.height, comp.pixelAspect, comp.duration);
adjustmentLayer.adjustmentLayer = true;
adjustmentLayer.name = "Adjustment Layer";
adjustmentLayer.startTime = startTime;
adjustmentLayer.inPoint = startTime;
adjustmentLayer.outPoint = startTime + duration;
adjustmentLayer.moveBefore(selectedLayer);
};
var nullButton = row1.add("button", undefined, "Null");
nullButton.size = [50, 25]; // Adjust button size as needed
nullButton.onClick = function() {
var project = app.project;
// Check if there is an active project
if (project === null) {
alert("No project open. Please open a project and try again.");
return;
}
// Get the active composition
var comp = project.activeItem;
// Check if the active item is a composition
if (comp === null || !(comp instanceof CompItem)) {
alert("No active composition. Please select an active composition and try again.");
return;
}
// Check if there are selected layers
if (comp.selectedLayers.length === 0) {
alert("No layers selected. Please select a layer and try again.");
return;
}
// Get the first selected layer
var selectedLayer = comp.selectedLayers[0];
// Get the start time and duration of the selected layer
var startTime = selectedLayer.inPoint;
var duration = selectedLayer.outPoint - selectedLayer.inPoint;
// Add a null layer to the composition
var nullLayer = comp.layers.addNull();
nullLayer.name = "Null Layer";
nullLayer.startTime = startTime;
nullLayer.inPoint = startTime;
nullLayer.outPoint = startTime + duration;
nullLayer.moveBefore(selectedLayer);
};
// Create the second row (single column)
var row2 = mainWindow.add("group");
row2.orientation = "row"; // Set orientation to row
// Add buttons to the second row
var shapeButton = row2.add("button", undefined, "Shape");
shapeButton.size = [50, 25]; // Adjust button size as needed
shapeButton.onClick = function() {
var project = app.project;
// Check if there is an active project
if (project === null) {
alert("No project open. Please open a project and try again.");
return;
}
// Get the active composition
var comp = project.activeItem;
// Check if the active item is a composition
if (comp === null || !(comp instanceof CompItem)) {
alert("No active composition. Please select an active composition and try again.");
return;
}
// Check if there are selected layers
if (comp.selectedLayers.length === 0) {
alert("No layers selected. Please select a layer and try again.");
return;
}
// Get the first selected layer
var selectedLayer = comp.selectedLayers[0];
// Get the start time and duration of the selected layer
var startTime = selectedLayer.inPoint;
var duration = selectedLayer.outPoint - selectedLayer.inPoint;
// Add a shape layer to the composition
var shapeLayer = comp.layers.addShape();
shapeLayer.name = "Shape Layer";
shapeLayer.startTime = startTime;
shapeLayer.inPoint = startTime;
shapeLayer.outPoint = startTime + duration;
shapeLayer.moveBefore(selectedLayer);
};
var cameraButton = row2.add("button", undefined, "Cam");
cameraButton.size = [50, 25]; // Adjust button size as needed
cameraButton.onClick = function() {
var project = app.project;
// Check if there is an active project
if (project === null) {
alert("No project open. Please open a project and try again.");
return;
}
// Get the active composition
var comp = project.activeItem;
// Check if the active item is a composition
if (comp === null || !(comp instanceof CompItem)) {
alert("No active composition. Please select an active composition and try again.");
return;
}
// Check if there are selected layers
if (comp.selectedLayers.length === 0) {
alert("No layers selected. Please select a layer and try again.");
return;
}
// Get the first selected layer
var selectedLayer = comp.selectedLayers[0];
// Get the start time and duration of the selected layer
var startTime = selectedLayer.inPoint;
var duration = selectedLayer.outPoint - selectedLayer.inPoint;
// Add a camera layer to the composition
var cameraLayer = comp.layers.addCamera("Camera", [comp.width *.5, comp.
height*.5]);
cameraLayer.name = "Camera";
cameraLayer.startTime = startTime;
cameraLayer.inPoint = startTime;
cameraLayer.outPoint = startTime + duration;
cameraLayer.moveBefore(selectedLayer);
};
var lightButton = row2.add("button", undefined, "Light");
lightButton.size = [50, 25]; // Adjust button size as needed
lightButton.onClick = function() {
var project = app.project;
// Check if there is an active project
if (project === null) {
alert("No project open. Please open a project and try again.");
return;
}
// Get the active composition
var comp = project.activeItem;
// Check if the active item is a composition
if (comp === null || !(comp instanceof CompItem)) {
alert("No active composition. Please select an active composition and try again.");
return;
}
// Check if there are selected layers
if (comp.selectedLayers.length === 0) {
alert("No layers selected. Please select a layer and try again.");
return;
}
// Get the first selected layer
var selectedLayer = comp.selectedLayers[0];
// Get the start time and duration of the selected layer
var startTime = selectedLayer.inPoint;
var duration = selectedLayer.outPoint - selectedLayer.inPoint;
// Add a light layer to the composition
comp.layers.addLight("My Light", [comp.width*.5, comp.height*
.5]);
lightLayer.name = "Light";
lightLayer.startTime = startTime;
lightLayer.inPoint = startTime;
lightLayer.outPoint = startTime + duration;
lightLayer.moveBefore(selectedLayer);
};
var textButton = row2.add("button", undefined, "Text");
textButton.size = [50, 25]; // Adjust button size as needed
textButton.onClick = function() {
var project = app.project;
// Check if there is an active project
if (project === null) {
alert("No project open. Please open a project and try again.");
return;
}
// Get the active composition
var comp = project.activeItem;
// Check if the active item is a composition
if (comp === null || !(comp instanceof CompItem)) {
alert("No active composition. Please select an active composition and try again.");
return;
}
// Check if there are selected layers
if (comp.selectedLayers.length === 0) {
alert("No layers selected. Please select a layer and try again.");
return;
}
// Get the first selected layer
var selectedLayer = comp.selectedLayers[0];
// Get the start time and duration of the selected layer
var startTime = selectedLayer.inPoint;
var duration = selectedLayer.outPoint - selectedLayer.inPoint;
// Add a text layer to the composition
var textLayer = comp.layers.addText("Text");
textLayer.name = "Text";
textLayer.startTime = startTime;
textLayer.inPoint = startTime;
textLayer.outPoint = startTime + duration;
textLayer.moveBefore(selectedLayer);
};
// Set spacing between rows
mainWindow.spacing = 5;
// Set background color
var brush = mainWindow.graphics.newBrush(mainWindow.graphics.BrushType.SOLID_COLOR, [9/255, 24/255, 28/255]);
mainWindow.graphics.backgroundColor = brush;
// Center and show the main window
if (mainWindow instanceof Window) {
mainWindow.center();
mainWindow.show();
} else {
mainWindow.layout.layout(true);
}
return mainWindow;
}
// Run the script as a dockable panel or a floating window
var myScriptPal = createUI(this);