I recorded applying the filter "Lighting Effects" and copied and pasted the resulting code into my script, replacing the parameters with variables. This works perfectly well, except for the selection of the channel, which looks like this:
Code: Select allvar idBmpC = charIDToTypeID( "BmpC" );
var ref20 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
ref20.putName( idChnl, "Alpha 1" );
desc35.putReference( idBmpC, ref20 );
I try to avoid referring to layers and channels by name (in this case "Alpha 1"), since they're not necessarily unique, but I don't know how to pass a channel (instanceof Channel) instead of its name (instanceof String) in this syntax. Any idea?
Script Listener - Passing a channel (and not its name)
Script Listener - Passing a channel (and not its name)
If you know the index of the channel, you may be able to do this instead of putting the name:
Code: Select allref20.putIndex( idChnl, 1);
I haven't tested this, however...
Code: Select allref20.putIndex( idChnl, 1);
I haven't tested this, however...
Script Listener - Passing a channel (and not its name)
Just to add to X's post. Action Manager( scriptlistener ) does not and can not use DOM objects so you can't pass a DOM channel reference to an Action Manager function. You can often use index instead of name but the index may not be the same as the DOM's index of that channel or layer.
For example even though a channel mask shows in the channel panel with a layer with a channel mask is active you can not select the mask by index with Action Manager. You also can't select the composite ( RGB, CNYK, etc ) channel by index.
For example even though a channel mask shows in the channel panel with a layer with a channel mask is active you can not select the mask by index with Action Manager. You also can't select the composite ( RGB, CNYK, etc ) channel by index.
Script Listener - Passing a channel (and not its name)
Ah well, the name will probably do for my purposes. Thanks, anyway!