forked from ff6347/after-effects-script-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-comp-apply-preset-from-selection.jsx
72 lines (60 loc) · 1.99 KB
/
make-comp-apply-preset-from-selection.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
var getFolder = function(_name) {
// function for gettin a specific folder
var bFolder;
for(var i = 1; i <= app.project.numItems; i++) {
if(app.project.item(i).name == _name && app.project.item(i) instanceof FolderItem) {
bFolder = app.project.item(i);
}
}
// if ther is no such folder, add it
if(!bFolder) {
bFolder = app.project.items.addFolder(_name);
}
return bFolder;
};
var main = function() {
var folder = Folder.myDocuments.fsName + '/Adobe/After Effects CC 2014/User Presets/';
var ffxone = 'jacobs-keylight-bildecke-01.ffx';
var ffxtwo = 'jacobs-keylight-bohnen-01.ffx';
var ffxthree = 'jacobs-keylight-bohnen-02.ffx';
var ffxfour = 'jacobs-keylight-braune-tuete-01.ffx';
var ffxfive = 'jacobs-keylight-kaffee-filter-01.ffx';
var ffxsix = 'jacobs-keylight-misc-haende-01.ffx';
var ffxseven = 'jacobs-keylight-kaffeeTrinken-01.ffx';
var ffxspill1 = 'jacobs-spill-surpress-01.ffx';
var ffxeight = '';
var presetfilepath = folder + ffxspill1; // "path/to/mypreset.ffx";
var pfile = File(presetfilepath);
if(pfile.exists !== true) {
alert('Presert file does not exist');
return;
}
app.beginUndoGroup('apply preset create comp');
var proj = app.project;
if(proj.selection <= 0) {
alert('Please select some images to prcess');
}else{
var folder = getFolder('greenscreen-precomps');
for(var i = 0; i < proj.selection.length; i++) {
if(proj.selection[i] instanceof FootageItem) {
var item = proj.selection[i];
var name = item.name + ' key';
var w = item.width;
var h = item.height;
var aspect = item.pixelAspect;
var fps = 25;
var dur = 1 / fps;
var keycomp = proj.items.addComp(name, w, h, aspect, dur, fps);
var layer = keycomp.layers.add(item, dur);
layer.applyPreset(pfile);
keycomp.parentFolder = folder;
keycomp.openInViewer();
}
}
}
app.endUndoGroup();
};
var run = function(func) {
func();
};
run(main);