Quantcast
Channel: Adobe Community : Popular Discussions - Photoshop Scripting
Viewing all articles
Browse latest Browse all 12244

Get the layername and Type the "Layer name" text at bottom of the layer

$
0
0

Hi all,

 

iam just trying the JavaScript in Photoshop I want place the name of the layer at the bottom of each layer. Please check the screen shot. I have tried but I get the same layer name repeatedly.

 

screen shot.jpg

 

 

    app.bringToFront();

    var docRef = app.activeDocument;

    var docName = decodeURI(activeDocument.name);

    var defaultRulerUnits = preferences.rulerUnits;

    preferences.rulerUnits = Units.PIXELS;

    var layerNum = app.activeDocument.artLayers.length;

    var layerRef = app.activeDocument.activeLayer;

    var x = layerRef.bounds[0].value;

    var y = layerRef.bounds[1].value;

    var coords = "";

       function recurseLayers(currLayers) {

    for ( var i = 0; i < currLayers.layers.length; i++ ) {

    layerRef = currLayers.layers[i];

    x = layerRef.bounds[0].value;

    y = layerRef.bounds[1].value;

   coords = layerRef.name + "," + x + "," + y

     var w =  app.activeDocument.width.value; 

    var h =  app.activeDocument.height.value; 

  createText("Arial-BoldMT", 18.0, 0,0,0, layerRef.name, x,y, "RIGHT")     

      }}

    function isLayerSet(layer) {

       }

     recurseLayers(docRef);

    preferences.rulerUnits = defaultRulerUnits; // Set preferences back to user 's defaults

     function createText(fface, size, colR, colG, colB, content, tX, tY, just) 

    { 

      var myLayerRef = app.activeDocument.artLayers.add() 

      myLayerRef.kind= LayerKind.TEXT 

      textColor = new SolidColor(); 

      textColor.rgb.red = colR; 

      textColor.rgb.green = colG; 

      textColor.rgb.blue = colB; 

       textItemRef = myLayerRef.textItem 

      textItemRef.font = fface; 

      textItemRef.contents = content; 

      textItemRef.color = textColor; 

      textItemRef.size = size 

      textItemRef.position = new Array(tX, tY) //pixels from the left, pixels from the top 

     textItemRef.position = new Array(tX, tY) //pixels from the left, pixels from the top 

     if (just == "CENTRE" || just == "CENTER" || just = "C" || just = "c") just = Justification.CENTER 

      else if (just == "RIGHT" || just == "right" || just = "R" || just = "r") just = Justification.RIGHT 

      else if (just == "LEFT" || just == "left" || just = "L" || just = "l") just = Justification.LEFT 

      else (just = Justification.LEFT) 

            activeDocument.activeLayer.textItem.justification = just 

    } 


Viewing all articles
Browse latest Browse all 12244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>