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

how to get fillcolor of multiple pathItems?

New Here ,
Aug 31, 2015 Aug 31, 2015

Copy link to clipboard

Copied

var paths = app.activeDocument.pathItems;

for (var a = 0; a < paths.length; a++) {

path.fillcolor // ti is undefined

}

who can tell me how to get fillcolor of multiple pathItems?

jelly

thx.

TOPICS
Actions and scripting

Views

502

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
Community Expert ,
Aug 31, 2015 Aug 31, 2015

Copy link to clipboard

Copied

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 ,
Aug 31, 2015 Aug 31, 2015

Copy link to clipboard

Copied

Moving to Photoshop Scripting forum.

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 ,
Sep 02, 2015 Sep 02, 2015

Copy link to clipboard

Copied

By the way: pathItems have no fill color per se, do you mean Shape Layers?

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
New Here ,
Sep 15, 2015 Sep 15, 2015

Copy link to clipboard

Copied

yeah,pathItems  is object of shapeLayers.

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 ,
Sep 15, 2015 Sep 15, 2015

Copy link to clipboard

Copied

Quote from the Object Model Viewer:

PathItems

Adobe Photoshop CC 2014 Object Library

The collection of path item objects in the document.

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
Participant ,
Sep 16, 2015 Sep 16, 2015

Copy link to clipboard

Copied

You can use

function setFillColor(clr) {

    var desc1 = new ActionDescriptor(),

        desc2 = new ActionDescriptor(),

        desc3 = new ActionDescriptor(),

        ref1 = new ActionReference();

    ref1.putEnumerated(stringIDToTypeID("contentLayer"), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));

    desc1.putReference(charIDToTypeID('null'), ref1);

    desc3.putDouble(charIDToTypeID('Rd  '), clr[0]);

    desc3.putDouble(charIDToTypeID('Grn '), clr[1]);

    desc3.putDouble(charIDToTypeID('Bl  '), clr[2]);

    desc2.putObject(charIDToTypeID('Clr '), stringIDToTypeID("RGBColor"), desc3);

    desc1.putObject(charIDToTypeID('T   '), stringIDToTypeID("solidColorLayer"), desc2);

    executeAction(charIDToTypeID('setd'), desc1, DialogModes.NO);

}

and

function getFillColor() {

    var ref = new ActionReference();

    ref.putEnumerated(stringIDToTypeID("contentLayer"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));

    var color = executeActionGet(ref).getList(charIDToTypeID("Adjs")).getObjectValue(0).getObjectValue(charIDToTypeID('Clr '));

    return [color.getDouble(charIDToTypeID('Rd  ')), color.getDouble(charIDToTypeID('Grn ')), color.getDouble(charIDToTypeID('Bl  '))];

}

For example: Set color for All Layers (with folders and subfolders)

var doc = app.activeDocument,

    allLayers = new Array();

collectAllShapeLayers(doc, 0);

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

    doc.activeLayer = allLayers;

    setFillColor([0, 30, 255]);

}

function setFillColor(clr) {

    var desc1 = new ActionDescriptor(),

        desc2 = new ActionDescriptor(),

        desc3 = new ActionDescriptor(),

        ref1 = new ActionReference();

    ref1.putEnumerated(stringIDToTypeID("contentLayer"), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));

    desc1.putReference(charIDToTypeID('null'), ref1);

    desc3.putDouble(charIDToTypeID('Rd  '), clr[0]);

    desc3.putDouble(charIDToTypeID('Grn '), clr[1]);

    desc3.putDouble(charIDToTypeID('Bl  '), clr[2]);

    desc2.putObject(charIDToTypeID('Clr '), stringIDToTypeID("RGBColor"), desc3);

    desc1.putObject(charIDToTypeID('T   '), stringIDToTypeID("solidColorLayer"), desc2);

    executeAction(charIDToTypeID('setd'), desc1, DialogModes.NO);

}

function collectAllShapeLayers(theParent, level) {

    for (var m = theParent.layers.length - 1; m >= 0; m--) {

        var theLayer = theParent.layers;

        if (theLayer.kind == "LayerKind.SOLIDFILL") {

            allLayers.push(theLayer);

        }

        if (theLayer.typename != "ArtLayer") {

            collectAllLayers(theLayer, level + 1)

        }

    }

}

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 ,
Sep 18, 2015 Sep 18, 2015

Copy link to clipboard

Copied

LATEST

Once again: Your terminology is off, pathItems are not identical to Shape Layers.

Anyway, you could try this:

// get rgb values for solid color layers with vector masks aka shape layers;

// 2015, use it at your own risk;

#target photoshop

if (app.documents.length > 0) {

main ();

};

////////////////////////////////////

function main () {

// the file;

var myDocument = app.activeDocument;

// get number of layers;

var ref = new ActionReference();

ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

var applicationDesc = executeActionGet(ref);

var theNumber = applicationDesc.getInteger(stringIDToTypeID("numberOfLayers"));

// process the layers;

var theLayers = new Array;

for (var m = 0; m <= theNumber; m++) {

try {

var ref = new ActionReference();

ref.putIndex( charIDToTypeID( "Lyr " ), m);

var layerDesc = executeActionGet(ref);

////////////////////////////////////

// collect values for solid color layers with vector masks;

if (layerDesc.hasKey(stringIDToTypeID('adjustment')) == true && layerDesc.getBoolean(stringIDToTypeID('hasVectorMask')) == true) {

var adjList = layerDesc.getList(stringIDToTypeID('adjustment'));

var theColors = adjList.getObjectValue(0).getObjectValue(stringIDToTypeID('color'));

var str = '';

for(var i=0;i<theColors.count;i++){

str = str + 'Key '+i+' = '+typeIDToStringID(theColors.getKey(i))+': '+theColors.getUnitDoubleValue(theColors.getKey(i))+'\n';

};

var theName = layerDesc.getString(stringIDToTypeID('name'));

var theID = layerDesc.getInteger(stringIDToTypeID('layerID'));

theLayers.push(["the layer »" +theName+"« has the layerID "+theID+" and the colors\n" +str])

};

}

catch (e) {};

};

alert (theLayers.join("\n"));

};

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