docsforadobe / aequery

MIT License
41 stars 8 forks source link

Snippet/starter function #24

Closed runegan closed 7 years ago

runegan commented 7 years ago

Original report by Rune Gangsø (Bitbucket: runegan, GitHub: runegan).


I notice that when I write short snippets that it often starts with something like this:

var comp = aeq.getActiveComp()
if ( comp === null ) {
    return alert( 'No Comp selected' )
}

var layers = comp.selectedLayers
if ( !layers.length ) {
    var applyToAll = confirm( 'No layers selected, apply to all?', false )
    if ( applyToAll ) {
        layers = aeq.getLayers( comp )
    } else {
        return
    }
}

aeq.undoGroup( 'Undo Group Name', main, [ layers ] )

I think it would be nice to have a function that does all that for you. Something like:

aeq.snippet.selectedOrAllLayers( 'Undo Group Name', function( layers ) {} )

I'm wondering if that is a good solution for it, or if there something else that can be done?

runegan commented 7 years ago

Original comment by Rune Gangsø (Bitbucket: runegan, GitHub: runegan).


See lib/modules/snippet