Hello,
I want o perform a "Layer via copy" on a layer when I have something selection. The script below doesn't work as I don't know what I'm doing!
My aim is to turn each channel of one layer into a new layer copied from a layer called "RGB". I hope this makes sense.
Code: Select allfunction main()
{
if (documents.length > 0)
{
// Create a reference to the active document.
var docRef = activeDocument
// Make some variables
var layerNum = docRef.artLayers.length // the number of layers
// Search through each layer to find the RGB layer
for(i=layerNum-1;i>=0;i--)
{
// search the layer name for the string to identify what layer it is
if(docRef.artLayers.name.indexOf("RGB")==0)
var RGBlayer = docRef.artLayers
}
docRef.selection.load(docRef.channels["Red"], SelectionType.REPLACE, false);
var newlayer = docRef.artLayers.add() //my target layer for the copied image
docRef.activeLayer = RGBlayer //make the RGB layer active
docRef.selection.copy()
docRef.newlayer.paste()
}
}
main();
Any help appreciated!
Josh.
Layer via copy
Layer via copy
OK I'm missing the semicolons. Still any help appreciated!
Code: Select allfunction main()
{
if (documents.length > 0)
{
// Create a reference to the active document.
var docRef = activeDocument
// Make some variables
var layerNum = docRef.artLayers.length // the number of layers
// Search through each layer to find the RGB layer
for(i=layerNum-1;i>=0;i--)
{
// search the layer name for the string to identify what layer it is
if(docRef.artLayers.name.indexOf("RGB")==0)
var RGBlayer = docRef.artLayers
}
docRef.selection.load(docRef.channels["Red"], SelectionType.REPLACE, false);
var newlayer = docRef.artLayers.add() //my target layer for the copied image
docRef.activeLayer = RGBlayer //make the RGB layer active
docRef.selection.copy();
docRef.paste();
}
}
main();
Code: Select allfunction main()
{
if (documents.length > 0)
{
// Create a reference to the active document.
var docRef = activeDocument
// Make some variables
var layerNum = docRef.artLayers.length // the number of layers
// Search through each layer to find the RGB layer
for(i=layerNum-1;i>=0;i--)
{
// search the layer name for the string to identify what layer it is
if(docRef.artLayers.name.indexOf("RGB")==0)
var RGBlayer = docRef.artLayers
}
docRef.selection.load(docRef.channels["Red"], SelectionType.REPLACE, false);
var newlayer = docRef.artLayers.add() //my target layer for the copied image
docRef.activeLayer = RGBlayer //make the RGB layer active
docRef.selection.copy();
docRef.paste();
}
}
main();
Layer via copy
Wow I know I ask the tough questions but I am surprised that no-one knows how to do a layer via copy!
J.
J.
Layer via copy
Are you joking or are you under some misapprehensions regarding this Forum?
And why do you post on the »General Discussion« Forum when you want assistance instead of on the »Help Me« Forum?
Edit: Furthermore I consider it less than ideal to reply to one’s own original post, especially more than once, as for me at least a post with 0 replies seems more noteworthy when I try to provide assistance than one that has already been addressed (repeatedly).
Anyway …
Code: Select all// layer via copy;
var id14 = charIDToTypeID( "CpTL" );
executeAction( id14, undefined, DialogModes.NO );
And why do you post on the »General Discussion« Forum when you want assistance instead of on the »Help Me« Forum?
Edit: Furthermore I consider it less than ideal to reply to one’s own original post, especially more than once, as for me at least a post with 0 replies seems more noteworthy when I try to provide assistance than one that has already been addressed (repeatedly).
Anyway …
Code: Select all// layer via copy;
var id14 = charIDToTypeID( "CpTL" );
executeAction( id14, undefined, DialogModes.NO );
Layer via copy
Hello pfaffenbichler,
Thank you for your response, it does work but I am unsure of how I can put the new layer into an variable. Using paste() I can simply assign it so, but the paste command does not always paste in place.
Code: Select allnewlayer = docRef.paste();
pfaffenbichler wrote:Are you joking or are you under some misapprehensions regarding this Forum?
Both maybe.
pfaffenbichler wrote:And why do you post on the »General Discussion« Forum when you want assistance instead of on the »Help Me« Forum?
Because I am new am am not yet completely confident with the structure of this form.
pfaffenbichler wrote:Edit: Furthermore I consider it less than ideal to reply to one’s own original post, especially more than once, as for me at least a post with 0 replies seems more noteworthy when I try to provide assistance than one that has already been addressed (repeatedly).
Interesting idea, I always found it useful when people post the progress they make rather than a "Oh solved it thanks" without ever telling anyone what they figured out. Plus more posts make more interesting reading.
Thank you for your response, it does work but I am unsure of how I can put the new layer into an variable. Using paste() I can simply assign it so, but the paste command does not always paste in place.
Code: Select allnewlayer = docRef.paste();
pfaffenbichler wrote:Are you joking or are you under some misapprehensions regarding this Forum?
Both maybe.
pfaffenbichler wrote:And why do you post on the »General Discussion« Forum when you want assistance instead of on the »Help Me« Forum?
Because I am new am am not yet completely confident with the structure of this form.
pfaffenbichler wrote:Edit: Furthermore I consider it less than ideal to reply to one’s own original post, especially more than once, as for me at least a post with 0 replies seems more noteworthy when I try to provide assistance than one that has already been addressed (repeatedly).
Interesting idea, I always found it useful when people post the progress they make rather than a "Oh solved it thanks" without ever telling anyone what they figured out. Plus more posts make more interesting reading.
Layer via copy
If someone has solved their original issue in a thread it is certainly considerate of them to explain that for the benefit of others who may have similar problems.
After »Layer Via Copy« you could define the newly created and thus active Layer as a new variable
Code: Select allvar id14 = charIDToTypeID( "CpTL" );
executeAction( id14, undefined, DialogModes.NO );
var theCopiedLayer = app.activeDocument.activeLayer;
After »Layer Via Copy« you could define the newly created and thus active Layer as a new variable
Code: Select allvar id14 = charIDToTypeID( "CpTL" );
executeAction( id14, undefined, DialogModes.NO );
var theCopiedLayer = app.activeDocument.activeLayer;
Layer via copy
Hi,
I see that makes perfect sense. Thanks again for your help.
Regards,
Josh.
I see that makes perfect sense. Thanks again for your help.
Regards,
Josh.