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

Is there description of the numeric 'layerKind' indexes that are available through AM?

Guide ,
Apr 22, 2019 Apr 22, 2019

Copy link to clipboard

Copied

Hello! For the script to work, I need to analyze the names of the layers of the document. I get a list of all the layers through AM, then in a loop I sort them in array according to desc.getInteger (stringIDToTypeID ('layerKind')). The problem is that layerKind comes in the form of a numeric index and, in case I need to match a specific type of layer in AM with the type of a layer in DOM,  and I need to understand what index it means. Is there description of the numeric 'layerKind' indexes that are available through AM?

TOPICS
Actions and scripting

Views

2.0K

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

correct answers 1 Correct answer

People's Champ , Apr 22, 2019 Apr 22, 2019

Taken from "C:/Program Files/Adobe/Adobe Photoshop CC 2018/Required/CopyCSSToClipboard.jsx"

// SheetKind definitions from USheet.h

const kAnySheet             = 0;

const kPixelSheet           = 1;

const kAdjustmentSheet      = 2;

const kTextSheet            = 3;

const kVectorSheet          = 4;

const kSmartObjectSheet     = 5;

const kVideoSheet           = 6;

const kLayerGroupSheet      = 7;

const k3DSheet              = 8;

const kGradientSheet        = 9;

const kPatternSheet         = 10;

const kSolidColor

...

Votes

Translate

Translate
Adobe
People's Champ ,
Apr 22, 2019 Apr 22, 2019

Copy link to clipboard

Copied

Taken from "C:/Program Files/Adobe/Adobe Photoshop CC 2018/Required/CopyCSSToClipboard.jsx"

// SheetKind definitions from USheet.h

const kAnySheet             = 0;

const kPixelSheet           = 1;

const kAdjustmentSheet      = 2;

const kTextSheet            = 3;

const kVectorSheet          = 4;

const kSmartObjectSheet     = 5;

const kVideoSheet           = 6;

const kLayerGroupSheet      = 7;

const k3DSheet              = 8;

const kGradientSheet        = 9;

const kPatternSheet         = 10;

const kSolidColorSheet      = 11;

const kBackgroundSheet      = 12;

const kHiddenSectionBounder = 13;

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
Explorer ,
Apr 19, 2023 Apr 19, 2023

Copy link to clipboard

Copied

Do you know when this index was established? This is giving me issues in CS5. It works fine in CC, but when checking the backward compatibility like explained in my other post you helped me with I am getting some errors. 

JustinCCC_0-1681933358508.png

JustinCCC_1-1681933373680.png

 

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
People's Champ ,
Apr 19, 2023 Apr 19, 2023

Copy link to clipboard

Copied

Will not work in CS5 and CS6. Also the property "hasBackgroundLayer" is not available (there will be an error). These properties are available with some version of CC, I can't tell which one.

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
Explorer ,
Apr 19, 2023 Apr 19, 2023

Copy link to clipboard

Copied

Oh boy, this is gonna be a long process for me haha. Thanks for the help!

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
Community Expert ,
Apr 19, 2023 Apr 19, 2023

Copy link to clipboard

Copied

LATEST

If the AM code is a problem for the older versions, perhaps you could use standard DOM code:

 

 

// http://creativetuts.com/photoshop-script-determine-layer-kind/
// Photoshop Script
// "Determine Layer Kind"
// Script by Mehmet Åžensoy
 
#target photoshop
app.bringToFront();

var doc = app.activeDocument;
var layer = doc.activeLayer;// Save selected layer to variable:

function determinelayerkind(layer) {
    if (layer.kind == LayerKind.TEXT) { layerkind = "Text Layer"; return layerkind; } // Text Layer
    else if (layer.kind == LayerKind.SOLIDFILL) { layerkind = "Shape Layer"; return layerkind; } /* Shape Layer */
    else if (layer.kind == LayerKind.BLACKANDWHITE) { layerkind = "Black and White adjustment layer"; return layerkind; } /* Black and White */
    else if (layer.kind == LayerKind.BRIGHTNESSCONTRAST) { layerkind = "Brightness contrast adjustment layer"; return layerkind; } /* Brightness contrast adjustment layer */
    else if (layer.kind == LayerKind.CHANNELMIXER) { layerkind = "Channel mixer adjustment layer"; return layerkind; } /* Channel mixer adjustment layer */
    else if (layer.kind == LayerKind.COLORBALANCE) { layerkind = "Color balance adjustment layer"; return layerkind; } /* Color balance adjustment layer */
    else if (layer.kind == LayerKind.CURVES) { layerkind = "Curves adjustment layer"; return layerkind; } /* Curves adjustment layer */
    else if (layer.kind == LayerKind.EXPOSURE) { layerkind = "Exposure layer"; return layerkind; } /* Exposure layer */
    else if (layer.kind == LayerKind.GRADIENTFILL) { layerkind = "Gradient fill"; return layerkind; } /* Gradient fill */
    else if (layer.kind == LayerKind.GRADIENTMAP) { layerkind = "Gradient map adjustment layer"; return layerkind; } /* Gradient map adjustment layer */
    else if (layer.kind == LayerKind.HUESATURATION) { layerkind = "Hue saturation adjustment layer"; return layerkind; } /* Hue saturation adjustment layer */
    else if (layer.kind == LayerKind.INVERSION) { layerkind = "Invert adjustment layer"; return layerkind; } /* Invert adjustment layer */
    else if (layer.kind == LayerKind.LAYER3D) { layerkind = "3D layer"; return layerkind; } /* 3D layer */
    else if (layer.kind == LayerKind.LEVELS) { layerkind = "Levels adjustment layer"; return layerkind; } /* Levels adjustment layer */
    else if (layer.kind == LayerKind.NORMAL) { layerkind = "Normal layer"; return layerkind; } /* Normal Layer */
    else if (layer.kind == LayerKind.PATTERNFILL) { layerkind = "Pattern fill layer"; return layerkind; } /* Pattern fill layer */
    else if (layer.kind == LayerKind.PHOTOFILTER) { layerkind = "Photo filter layer"; return layerkind; } /* Photo filter layer */
    else if (layer.kind == LayerKind.POSTERIZE) { layerkind = "Posterize adjustment layer"; return layerkind; } /* Posterize adjustment layer */
    else if (layer.kind == LayerKind.SELECTIVECOLOR) { layerkind = "Selective color adjustment layer."; return layerkind; } /* Selective color adjustment layer */
    else if (layer.kind == LayerKind.SMARTOBJECT) { layerkind = "Smart object layer"; return layerkind; } /* Smart object layer */
    else if (layer.kind == LayerKind.THRESHOLD) { layerkind = "Threshold adjustment layer"; return layerkind; } /* Threshold adjustment layer */
    else if (layer.kind == LayerKind.VIBRANCE) { layerkind = "Vibrance layer"; return layerkind; } /* Vibrance layer */
    else if (layer.kind == LayerKind.VIDEO) { layerkind = "Video layer"; return layerkind; } /* Video layer */

    else if (app.activeDocument.activeLayer.typename === "LayerSet" && app.activeDocument.activeLayer.layers.length === 0) { layerkind = "Layer Set"; return layerkind; } /* Layer Set */
    else if (app.activeDocument.activeLayer.typename === "LayerSet" && app.activeDocument.activeLayer.layers.length > 0) { layerkind = "Layer Set + Content"; return layerkind; } /* Layer Set - Must have content */
}

alert("Current Layer is a " + determinelayerkind(layer));

 

 

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
Explorer ,
Aug 12, 2019 Aug 12, 2019

Copy link to clipboard

Copied

Thanks

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