Skip to main content
Inspiring
July 25, 2013
解決済み

How to get the fill color of shape or solid color fill layers?

  • July 25, 2013
  • 返信数 1.
  • 1778 ビュー

Hi All,

I am trying to get the fill color values of shape or solid color fill layers.

I get the kind of active layer i.e. SOLIDFILL, but there is no color like property to get the color for shape or solid color fill layers.

Is there any way or script to do that?

Please help me on this.

Thanks,
AI

このトピックへの返信は締め切られました。
解決に役立った回答 c.pfaffenbichler

I have not bothered with checking the type of the active layer, but if one Solid Color Layer is selected this should help.

// based on code by michael l hale;

var ref = new ActionReference();

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

var layerDesc = executeActionGet(ref);

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

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

var str = '';

for(var i=0;i<theColors.count;i++){ //enumerate descriptor's keys

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

}

alert(str);

返信数 1

c.pfaffenbichler
Community Expert
Community Expert
July 25, 2013

I have not bothered with checking the type of the active layer, but if one Solid Color Layer is selected this should help.

// based on code by michael l hale;

var ref = new ActionReference();

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

var layerDesc = executeActionGet(ref);

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

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

var str = '';

for(var i=0;i<theColors.count;i++){ //enumerate descriptor's keys

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

}

alert(str);

AI_learner作成者
Inspiring
July 25, 2013

Thanks a lot, this is exactly what i need..

c.pfaffenbichler
Community Expert
Community Expert
July 25, 2013

You’re welcome.