Need script that check selection content and count layers

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

DanielR

Need script that check selection content and count layers

Post by DanielR »

Je vous remercie! Maintenant, le script est apparu dans le menu script d'une fois que j'ai ouvert CS6, mais la prochaine fois ne pas montrer? Étrange .. Je pense qu'il est CS6 bug.

Script fonctionne presque parfait maintenant, sauf qu'il ne vérifie pas la dernière couche. S'il ya un point là-bas, ce ne sera pas le compter et ne pas faire calque visible.

Je dois vous remercier encore une fois pour votre aide, vous êtes très utile. J'ai essayé de changer les critères de boucle <à <=, mais il ne fonctionne pas, le script s'est écrasé. Je crois que c'est une sorte d'erreur de boucle mineure vérifier une couche inférieure dans la pile.

Que pensez-vous?

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

txuku

Need script that check selection content and count layers

Post by txuku »

I modified the script lines 31 and 50 :
Code: Select all//desactiveTransparent.jsx

var docRef = activeDocument;
var selAlpha = docRef.channels.add();
//selAlpha.name = "test";
docRef.selection.store(selAlpha) //Memoriser la selection
var calcOpacity = 50; //opacite des calques en %
var num = new Array;
var k = 0;

for ( j=0;j<docRef.layers.length;j++) //masquer tous les calques
     {
        docRef.layers[j].visible=false;
     }
//var Blanc = new SolidColor();
//Blanc.rgb.red=Blanc.rgb.green=Blanc.rgb.blue=255;

if (docRef.layers.length > 1)
{
  // docRef.layers[docRef.layers.length].visible=false; //masque le calque d arriere plan
   
   for(i=0; i < docRef.layers.length; i++)
  {
      docRef.activeLayer = docRef.layers;
      docRef.layers.visible = true;
     
      try
      {
        //docRef.selection.selectAll();
        docRef.selection.load(selAlpha); //docRef.channels["test"] );//selAlpha
        if(i!=0)
        {
        docRef.activeLayer = docRef.layers[i-1];
        }
        else
        {
          docRef.activeLayer = docRef.layers[i+1];
        } 
        docRef.activeLayer = docRef.layers;
        docRef.selection.copy();
        docRef.selection.deselect();
        docRef.layers.visible = false;
     
      }
      catch(e)  //si la selection est vide : erreur pour copy()
      {
          docRef.layers.visible = false;
          num[k] = i;
          k=k+1;
          docRef.selection.deselect();
      }
   }   
}

//alert(num)

for(i=0; i < docRef.layers.length;  i++)  // rend tous les calques visibles
{
      docRef.activeLayer = docRef.layers;
      docRef.layers.visible = true;
      docRef.layers.opacity = calcOpacity;
}       

//docRef.layers[docRef.layers.length].visible=true;  //arriere plan visible

for(i=0; i < num.length; i++)   // masque les calques selectionnes tout blancs
{
      docRef.activeLayer = docRef.layers[num];
      docRef.layers[num].visible = false;
}

//docRef.activeLayer = docRef.layers[docRef.layers.length-1] //rend l arriere plan actif
docRef.selection.load(selAlpha); //docRef.channels["test"] );//selAlpha
var calcVis = (docRef.layers.length) - num.length;
alert( "Number of Dots in position = " + calcVis );// JavaScript Document
DanielR

Need script that check selection content and count layers

Post by DanielR »

Thank you VERY VERY much !!!! No the script works perfectly.. except that it wont show in script menu, but that must be a bug in CS6.

Thank you very much.
txuku

Need script that check selection content and count layers

Post by txuku »

Ouf !