Copy link to clipboard
Copied
HI everyone, i have to be able to select a path named 'skin' or "Skin' at times, then again for 'outfit or 'Outfit' and then turn the selection on for each. can that be done with a an if statement?
Copy link to clipboard
Copied
I sure you will be able to get a list of path names in the path palette and test which paths are in there if any of the name you want are there or not. Any that are there I' sure you could load as a selection or modify the active selection with add for sure you may need to create alpha channels if you want to combine is other ways.
Copy link to clipboard
Copied
thanks JJMack, any idea how to begin to write the code for that?
Copy link to clipboard
Copied
Hi bflieck,
Hope this help you.
if(app.documents.length>0){
var docRef = app.activeDocument;
var mypath = docRef.pathItems;
for (var i = 0; i < mypath.length; i++) {
alert(mypath.name);
if(mypath.name=="skin" || mypath.name=="Skin" || mypath.name=="outfit" || mypath.name=="Outfit"){
mypath.makeSelection(0.3);
alert("This Selection from path name : "+mypath.name);
}
else{flag=1}
}
}
-yajiv
Copy link to clipboard
Copied
How do you want to combine them? What is var flag for?
if(app.documents.length>0){
var docRef = app.activeDocument;
activeDocument.selection.deselect();
var mypath = docRef.pathItems;
for (var i = 0; i < mypath.length; i++) {
//alert(mypath.name);
if(mypath.name=="skin" || mypath.name=="Skin" || mypath.name=="outfit" || mypath.name=="Outfit"){
// Feather, antiAlias True|False, SelectionType DIMINISH EXTEND NTERSECT REPLACE
mypath.makeSelection(0.3,false,SelectionType.EXTEND);
//alert("This Selection from path name : "+mypath.name);
}
else{flag=1}
}
}
Copy link to clipboard
Copied
Hi JJMAck,
Thank you for letting me know. I forget to extend the path selection.
mypath.makeSelection(0.3,false,SelectionType.EXTEND);
-yajiv
Copy link to clipboard
Copied
Hi Natrev, this is close. i need the selection to happen on "skin", or "Skin" so i can "layer via copy" to a new layer from the background layer, then go back to the same background layer, and make the selection "outfit" or, "Outfit" and make layer via copy.
does that make sense?
thanks!
Copy link to clipboard
Copied
Hi bflieck,
Hope this code will help.
cTID = function(s) {return app.charIDToTypeID(s);};
sTID = function(s) {return app.stringIDToTypeID(s);};
if(app.documents.length>0){
var docRef = app.activeDocument;
activeDocument.selection.deselect();
var flag=1;
var pathFound = '';
var mypath = docRef.pathItems;
for (var i = 0; i < mypath.length; i++) {
if(mypath.name=="skin" || mypath.name=="Skin"){ DupLayer(docRef,mypath);}
else if(mypath.name=="outfit" || mypath.name=="Outfit"){DupLayer(docRef,mypath);}
}
}
function DupLayer(docRef,lyr){
docRef.activeLayer=docRef.backgroundLayer;
lyr.makeSelection(0.3);
executeAction( cTID( "CpTL" ), undefined, DialogModes.NO );
docRef.activeLayer.name=lyr.name;
}
-yajiv
Copy link to clipboard
Copied
You would need to code the whole process in the script so the path would be process in the correct order if stack order is important so the layers via copy would be in the correct stacking order over the background or bottom layer in case you want to be able to have a bottom layer that is not a background like a RAW file opened as a smart object layer. A document need not have a actual Photoshop background layer. It would also be possible to have all four path in a document.
Or you could combine all the skin and outfit paths and create a single combined layer.
if(app.documents.length>0){
var docRef = app.activeDocument;
activeDocument.selection.deselect();
var flag=1;
var pathFound = '';
var mypath = docRef.pathItems;
for (var i = 0; i < mypath.length; i++) {
//alert(mypath.name);
if(mypath.name=="skin" || mypath.name=="Skin" || mypath.name=="outfit" || mypath.name=="Outfit"){
// Feather, antiAlias True|False, SelectionType DIMINISH EXTEND NTERSECT REPLACE
pathFound = pathFound + mypath.name + " ";
mypath.makeSelection(0.3,false,SelectionType.EXTEND);
flag=0;
//alert("This Selection from path name : "+mypath.name);
}
}
}
if (flag) alert("A Required Path was not found");
else { // alert("Selection from " +pathFound)
var layers = activeDocument.layers;
activeDocument.activeLayer = layers[layers.length-1] // Target Bottom Layer
var idCpTL = charIDToTypeID( "CpTL" );
executeAction( idCpTL, undefined, DialogModes.NO );
activeDocument.activeLayer.name=pathFound;
}
Copy link to clipboard
Copied
That flag you have is questionable you may want sonething like this;
if(app.documents.length>0){
var docRef = app.activeDocument;
activeDocument.selection.deselect();
var flag=1;
var pathFound = '';
var mypath = docRef.pathItems;
for (var i = 0; i < mypath.length; i++) {
//alert(mypath.name);
if(mypath.name=="skin" || mypath.name=="Skin" || mypath.name=="outfit" || mypath.name=="Outfit"){
// Feather, antiAlias True|False, SelectionType DIMINISH EXTEND NTERSECT REPLACE
pathFound = pathFound + mypath.name + " ";
mypath.makeSelection(0.3,false,SelectionType.EXTEND);
flag=0;
//alert("This Selection from path name : "+mypath.name);
}
}
}
if (flag) alert("A Required Path was not found");
else alert("Selection from " +pathFound)