• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Determining if the layer link is turned on or off

Contributor ,
Oct 20, 2016 Oct 20, 2016

Copy link to clipboard

Copied

Hi,

With scriptListener plugin I was able to log the layer link turn off actions:

var iddisableLayerLink = stringIDToTypeID( "disableLayerLink" );

    var desc5 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref2 = new ActionReference();

        var idLyr = charIDToTypeID( "Lyr " );

        var idOrdn = charIDToTypeID( "Ordn" );

        var idTrgt = charIDToTypeID( "Trgt" );

        ref2.putEnumerated( idLyr, idOrdn, idTrgt );

    desc5.putReference( idnull, ref2 );

    var idT = charIDToTypeID( "T   " );

        var desc6 = new ActionDescriptor();

        var idlnkE = charIDToTypeID( "lnkE" );

        desc6.putBoolean( idlnkE, false );

    var idLyr = charIDToTypeID( "Lyr " );

    desc5.putObject( idT, idLyr, desc6 );

executeAction( iddisableLayerLink, desc5, DialogModes.NO );

How can I retrieve the boolean which is indicating the turned on/off state of the layer's link?

Thanks a lot!

TOPICS
Actions and scripting

Views

788

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
LEGEND ,
May 20, 2018 May 20, 2018

Copy link to clipboard

Copied

LATEST

If you are in CS6 EXTENDED, where AM was still limited you can use this script (however it works in higher versions too):

$.level = 0; function sTT(v) {return stringIDToTypeID(v)}

function layer(v1, v2){

     try{

          (ref = new ActionReference()).putIndex(l = sTT('layer'), 0)

          if (((iN = isNaN(v1)) && v2) || !iN && !v2 && v1 != null) {

               executeActionGet(ref).getBoolean(sTT('background'))

          }

     }

     catch (err) {v1++}

     nu = v1 != undefined, eval("(ref = new ActionReference()).put" +

     (nu ? (iN ? "Name" : (v2 ? "Identifier" : "Index")) : "Enumerated") +

     "(l, " + (nu ? "v1" : "sTT('ordinal'), sTT('targetEnum')") + ")")

     if ((dsc = executeActionGet(ref)).hasKey(sTT('linkedLayerIDs'))) {

          with(psd = new PhotoshopSaveOptions()) {

               layers = !(spotColors = alphaChannels =

               embedColorProfile = annotations = false)

          }

          activeDocument.saveAs(fle = File('~/desktop/.psd'), psd, true)

          var m, lnk = dsc.getInteger(sTT('itemIndex')); (function() {

               fle.encoding = 'binary', fle.open('r'); var r = fle.read()

               index = r.indexOf('8BIM\x040'), fle.seek(index + 10)

               function bin(v) {return v * fle.readch().charCodeAt()}

               var d = fle.read(bin(256) + bin(1)), re = /\x00/g

               while(re.exec(d)) if (m = re.lastIndex == lnk) {break}

               fle.close(), fle.remove(); return m // DLL index

          })()

     }

     return Boolean(!m)

}

Examples how to use layer()​:

layer()     /     active layer

layer('layer 1')     /     layer 1

layer(1, true)     /     identifier 1

layer(0)     /     index 1 or background

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines