Last active
August 29, 2015 14:10
-
-
Save dokluch/36d417e5470ed24f5f2b to your computer and use it in GitHub Desktop.
Creates a null object parented to all selected layers in Adobe After Effects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createNull(){ | |
var activeComp = app.project.activeItem; | |
if(!activeComp instanceof CompItem || !activeComp){ | |
alert("No comp selected"); | |
return null; | |
} | |
app.beginUndoGroup("Creatin a null"); | |
if(activeComp.selectedLayers.length != 0){//и если на композиции выделены какие-то слои | |
var sel = activeComp.selectedLayers; | |
//сортируем по убыванию | |
sel.sort(function(a,b){ | |
return a.index - b.index; | |
}); | |
//создаем нуль и кидаем выше самого верхнего | |
var newNull = activeComp.layers.addNull(activeComp.duration); | |
newNull.moveBefore(sel[0]); | |
for(var l = 0; l < sel.length; l++){ | |
sel[i].parent = newNull;//привязываемся ко всем выбранным слоям | |
} | |
} | |
else var newNull = activeComp.layers.addNull(activeComp.duration);//создаем нулл | |
app.endUndoGroup(); | |
} | |
createNull(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment