-
Notifications
You must be signed in to change notification settings - Fork 0
/
Q_Spans_v1.jsx
99 lines (81 loc) · 3.22 KB
/
Q_Spans_v1.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
// Create UI
function createUIPanel(thisObj) {
// Create a new window
var uiPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Q Spans", undefined, { resizeable: true });
if (uiPanel !== null) {
// Add buttons to the UI
var btnQueueComp = uiPanel.add("button", undefined, "Q Comp Spans");
var btnQueueLayer = uiPanel.add("button", undefined, "Q Layer Spans");
// Set button callbacks
btnQueueComp.onClick = queueCompMarkerSpans;
btnQueueLayer.onClick = queueLayerMarkerSpans;
// Set layout and properties
uiPanel.orientation = "column";
uiPanel.alignChildren = "center";
// Resize the panel when the window is resized
uiPanel.layout.layout(true);
uiPanel.layout.resize();
uiPanel.onResizing = uiPanel.onResize = function() {
this.layout.resize();
}
}
return uiPanel;
}
function queueCompMarkerSpans() {
// Selected Composition
var comp = app.project.activeItem;
// Check if a composition is selected
if (!comp || !(comp instanceof CompItem)) {
alert("Please select a composition.");
return;
}
// Composition markers
var compMarkers = comp.markerProperty;
// Project file path
var projPath = app.project.file.path;
// Check if the composition has markers
if (compMarkers.numKeys > 0) {
for (var i = 1; i <= compMarkers.numKeys; i++) {
var item = app.project.renderQueue.items.add(comp);
item.timeSpanStart = compMarkers.keyTime(i);
item.timeSpanDuration = compMarkers.keyValue(i).duration;
var output = item.outputModules[1];
var outputFilePath = projPath + "/_Renders/" + comp.name + "_" + compMarkers.keyValue(i).comment;
output.file = new File(outputFilePath);
}
} else {
alert("The selected composition has no markers.");
}
}
function queueLayerMarkerSpans() {
// Selected Composition
var comp = app.project.activeItem;
// Check if a composition is selected
if (!comp || !(comp instanceof CompItem)) {
alert("Please select a composition.");
return;
}
// Selected Layer
var spanLayer = comp.selectedLayers[0]; // Assuming you want the first selected layer
// Check if a layer is selected
if (!spanLayer) {
alert("Please select a layer.");
return;
}
// Project file path
var projPath = app.project.file.path;
var layerMarkers = spanLayer.property("Marker");
if (layerMarkers.numKeys > 0) {
for (var i = 1; i <= layerMarkers.numKeys; i++) {
var item = app.project.renderQueue.items.add(comp);
item.timeSpanStart = layerMarkers.keyTime(i);
item.timeSpanDuration = layerMarkers.keyValue(i).duration;
var output = item.outputModules[1];
var outputFilePath = projPath + "/_Renders/" + comp.name + "_" + layerMarkers.keyValue(i).comment;
output.file = new File(outputFilePath);
}
} else {
alert("The selected layer has no markers.");
}
}
createUIPanel(this)