Copy link to clipboard
Copied
Hi Everyone!,
Is it possible to get layer, layerset and layer with in layerset status. Since I have faced big problem beyond this.
I have an one PS document which is contain collection of layer, collection layersets with layer. I need apply function for each layer and layersets and all layers with in layerset.
Also I tried one code but its getting error. Please help me to out this code...
-yajiv
#target photoshop
app.bringToFront();
$.level=2;
var docRef = app.activeDocument;
var log="";
var x=0;
var n=Number(docRef.layers.length)-1;
for (i=0;i<n;i++){
var tm=String(docRef.layers);
var isLayer=tm.lastIndexOf("ArtLayer");
var isLayerSet=tm.lastIndexOf("LayerSet");
if(isLayer!=-1){
Check_LayerStructure(docRef.layers,"Layer");
}
if(isLayerSet!=-1){
Check_LayerStructure(docRef.layerSets,"LayerSets");
x=x+1;
}
}
function Check_LayerStructure(objLayer,objflag,x){ \
if(objflag=="Layer"){
LayetStructure(objLayer,objLayer.name,BlendMode.NORMAL,100,100,0,true," Layer ");
}
else if(objflag=="LayerSets"){
LayetStructure(objLayer
m=Number(objLayer
for (j=0;j<m;j++){
var tm=String(objLayer
var isLayer=tm.lastIndexOf("ArtLayer");
var isLayerSet=tm.lastIndexOf("LayerSet");
if(isLayer!=-1){
Check_LayerStructure(objLayer
}
if(isLayerSet!=-1){
Check_LayerStructure(objLayer
}
} // Layerset Loop
}// I For Loop
}//Function loop
function LayetStructure(layerRef,L,bMode,Opt,fillOpt,S,layVisible,Lref){
if(layerRef.blendMode!=bMode){
if (confirm (L + Lref+"belend mode was wrong...!!!\n"+"Do you want to change....?")){
layerRef.blendMode=bMode;
log=log+"- " +L+ Lref+ "belend mode was changed...!!!\n\n";
e=1;
}
}
if(layerRef.opacity!=Opt) {
if (confirm (L + Lref+ "Opacity was "+Math.round(layerRef.opacity)+"%...!!!\n"+"Do you want to change....?")){
layerRef.opacity=Opt;
log=log+"- " + L + Lref+ "Opacity was changed to 100...!!!\n\n";
e=1;
}
}
if(layerRef.fillOpacity!=fillOpt && S==0) {
if (confirm (L + Lref+ "Fill was "+Math.round(layerRef.fillOpacity)+"%...!!!\n"+"Do you want to change....?")){
layerRef.fillOpacity=fillOpt;
log=log+"- " + L + Lref+ "Fill was changed to 100...!!!\n\n";
e=1;
}
}
if(layerRef.visible!=layVisible) {
if (L + Lref+ "eye was off..!!!\n"+"Do you want to change....?"){
layerRef.visible=layVisible;
log=log+"- " + L + Lref+ "eye was turn into on...!!!\n\n";
e=1;
}
}
}
Action Manager code would naturally be faster, but if you should be more comfortable with DOM code this might be of use to you.
...
#target photoshop
var theLayers = collectLayers(app.activeDocument, []);
alert (theLayers.join("\n"));
////// function collect all layers //////
function collectLayers (theParent, allLayers) {
if (!allLayers) {var allLayers = new Array}
else {};
var theNumber = theParent.layers.length - 1;
for (var m = theNumber; m >= 0;m--) {
var theLayer = theParent.layers
Copy link to clipboard
Copied
What exactly do you need to get?
Please provide a screenshot of the Layers Panel and a text representing the information you want to get for those Layers/LayerSets …
Copy link to clipboard
Copied
Hi c.pfaffenbichler,
Thanks for your reply. What I need exactly mentioned below.
1. I need to check Layer property whether layer has 100% opacity and blend mode Normal
2. As well as check layerset property whether layerset has 100% fillopacity and blend mode is PASS THROUGH
3. In Photoshop document has many layer and layerset. As well as the layerset has many layer and layerset.
4. I need create recursive function to check all layers and layerset....
Thanks in advance.
-- yajiv
Copy link to clipboard
Copied
Action Manager code would naturally be faster, but if you should be more comfortable with DOM code this might be of use to you.
#target photoshop
var theLayers = collectLayers(app.activeDocument, []);
alert (theLayers.join("\n"));
////// function collect all layers //////
function collectLayers (theParent, allLayers) {
if (!allLayers) {var allLayers = new Array}
else {};
var theNumber = theParent.layers.length - 1;
for (var m = theNumber; m >= 0;m--) {
var theLayer = theParent.layers
; // apply the function to layersets;
if (theLayer.typename == "ArtLayer") {
allLayers.push([theLayer, theLayer.blendMode, theLayer.opacity, theLayer.fillOpacity])
}
else {
allLayers = (collectLayers(theLayer, allLayers))
// this line includes the layer groups;
allLayers.push([theLayer, theLayer.blendMode, theLayer.opacity, theLayer.fillOpacity]);
}
};
return allLayers
};
Copy link to clipboard
Copied
Hi c.pfaffenbichler!
Kudos and thank you for your marvelous support. You are too good and i did not think about that side.
This what I needed. Your are much appreciated.
-- yajiv
Copy link to clipboard
Copied
Should the Script take too long to be useful an Action Manager alternative would be possible..