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

Display the layer color of the active layer stroke

Engaged ,
Nov 18, 2020 Nov 18, 2020

Copy link to clipboard

Copied

Hello everyone!
Is there any way to check the color code of the stroke applied to the layer with active effects with scripts? Thanks.

vvvccdd.png

TOPICS
Actions and scripting

Views

430

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

Guide , Nov 18, 2020 Nov 18, 2020

Here is an example for active layer....

var S ={}
S = getStrokeFX();
for(var a in S){
    $.writeln(a + " = " + S[a]);
}

function getStrokeFX(){
var Stroke ={};
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
var desc = executeActionGet(ref);
if(desc.hasKey(stringIDToTypeID( 'layerEffects' ))){
if(!desc.getBoolean (stringIDToTypeID( 'layerFXVisible'))) return undefined;
desc = desc.getObjectValue(stringIDToTypeID('lay
...

Votes

Translate

Translate
Adobe
Community Expert ,
Nov 18, 2020 Nov 18, 2020

Copy link to clipboard

Copied

It may be possible with Action Manager code to see what is recorder in a layer's layer style.  A layer style can have many effects and there can be more that a single stroke effect in a layer's layer style with different opacity. The scripting may be complex and one would need to know how to use Action manager code.  If would be above my pay grade.

 

It is very easy to check  by editing the current layer style. Color sampler will not work for the opacity does not have to be 100% and blending mode may nor be normal.

image.png

 

JJMack

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
Guide ,
Nov 18, 2020 Nov 18, 2020

Copy link to clipboard

Copied

Here is an example for active layer....

var S ={}
S = getStrokeFX();
for(var a in S){
    $.writeln(a + " = " + S[a]);
}

function getStrokeFX(){
var Stroke ={};
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
var desc = executeActionGet(ref);
if(desc.hasKey(stringIDToTypeID( 'layerEffects' ))){
if(!desc.getBoolean (stringIDToTypeID( 'layerFXVisible'))) return undefined;
desc = desc.getObjectValue(stringIDToTypeID('layerEffects'));
if(!desc.hasKey(stringIDToTypeID( 'frameFX'))) return null;
desc = desc.getObjectValue(stringIDToTypeID('frameFX'));
Stroke.Enabled = desc.getBoolean(stringIDToTypeID('enabled'));
Stroke.Mode = typeIDToStringID(desc.getEnumerationValue( stringIDToTypeID( 'mode' )));
Stroke.Style = typeIDToStringID(desc.getEnumerationValue( stringIDToTypeID( 'style' )));
Stroke.PaintType = typeIDToStringID(desc.getEnumerationValue( stringIDToTypeID( 'paintType' )));
Stroke.Opacity = desc.getUnitDoubleValue (stringIDToTypeID( 'opacity' ));
Stroke.Size = desc.getUnitDoubleValue (stringIDToTypeID( 'size' ));
if(desc.hasKey (stringIDToTypeID('color'))){
var cColour = getColorFromDescriptor(desc.getObjectValue(stringIDToTypeID("color")), typeIDToCharID(desc.getClass(stringIDToTypeID("color"))));
Stroke.Colour = cColour.rgb.hexValue;
}
if(desc.hasKey (stringIDToTypeID('gradient'))){
Stroke.Angle  = desc.getUnitDoubleValue (stringIDToTypeID( 'angle' ));
Stroke.Type = typeIDToStringID(desc.getEnumerationValue( stringIDToTypeID( 'type' )));
Stroke.Reverse = desc.getBoolean(stringIDToTypeID('reverse'));
Stroke.Dither = desc.getBoolean(stringIDToTypeID('dither'));
Stroke.Scale = desc.getUnitDoubleValue (stringIDToTypeID( 'scale' ));
Stroke.Align = desc.getBoolean(stringIDToTypeID('align'));
var gradientDesc = desc.getObjectValue(stringIDToTypeID('gradient'));
Stroke.Name = gradientDesc.getString(stringIDToTypeID('name'));
Stroke.GradientForm = typeIDToStringID(gradientDesc.getEnumerationValue( stringIDToTypeID( 'gradientForm' )));
Stroke.InterfaceIconFrameDimmed  = gradientDesc.getUnitDoubleValue (stringIDToTypeID( 'interfaceIconFrameDimmed' ));
var colorDesc = gradientDesc.getList(stringIDToTypeID( 'colors'));
var cCount = colorDesc.count;
Stroke.GradientColours = [];
Stroke.GradientType = [];
Stroke.GradientLocation = [];
Stroke.GradientMidpoint = [];
for(var a = 0;a<cCount;a++){
   var gradDesc = desc.getObjectValue(stringIDToTypeID('gradient')).getList(stringIDToTypeID('colors')).getObjectValue(a);
   var gColour = getColorFromDescriptor(gradDesc.getObjectValue(stringIDToTypeID("color")), typeIDToCharID(gradDesc.getClass(stringIDToTypeID("color"))));
Stroke.GradientColours.push(gColour.rgb.hexValue);
Stroke.GradientType.push(typeIDToStringID(gradDesc.getEnumerationValue( stringIDToTypeID( 'type' ))));
Stroke.GradientLocation.push(gradDesc.getInteger (stringIDToTypeID( 'location' )));
Stroke.GradientMidpoint.push(gradDesc.getInteger (stringIDToTypeID( 'midpoint' )));
    }
var tranDesc = gradientDesc.getList(stringIDToTypeID( 'transparency'));
var tCount = tranDesc.count;
Stroke.TransparencyOpacity = [];
Stroke.TransparencyLocation = [];
Stroke.TransparencyMidpoint = [];
for(var a = 0;a<tCount;a++){
   var tDesc = desc.getObjectValue(stringIDToTypeID('gradient')).getList(stringIDToTypeID('transparency')).getObjectValue(a);
Stroke.TransparencyOpacity.push(tDesc.getUnitDoubleValue (stringIDToTypeID( 'opacity' )));
Stroke.TransparencyLocation.push(tDesc.getInteger (stringIDToTypeID( 'location' )));
Stroke.TransparencyMidpoint.push(tDesc.getInteger (stringIDToTypeID( 'midpoint' )));
   }
var offsetDesc = desc.getObjectValue(stringIDToTypeID('offset'));
Stroke.OffsetHorizontal = offsetDesc.getUnitDoubleValue (stringIDToTypeID( 'horizontal' ));
Stroke.OffsetVertical = offsetDesc.getUnitDoubleValue (stringIDToTypeID( 'vertical' ));
    }
if(desc.hasKey (stringIDToTypeID('pattern'))){
var patternDesc = desc.getObjectValue(stringIDToTypeID('pattern'));
Stroke.Scale = desc.getUnitDoubleValue (stringIDToTypeID( 'scale' ));
Stroke.Linked = desc.getBoolean(stringIDToTypeID('linked'));
Stroke.PatternName = patternDesc.getString(stringIDToTypeID('name'));
Stroke.PatternID = patternDesc.getString(stringIDToTypeID('ID'));
var phaseDesc = desc.getObjectValue(stringIDToTypeID('phase'));
Stroke.PatternHorizontal = phaseDesc.getUnitDoubleValue (stringIDToTypeID( 'horizontal' ));
Stroke.PatternVertical = phaseDesc.getUnitDoubleValue (stringIDToTypeID( 'vertical' ));
    }
}

return Stroke;
};
function getColorFromDescriptor(colorDesc, keyClass) {
  var colorObject = new SolidColor();
  switch (keyClass) {
  case "Grsc":
    colorObject.grey.grey = color.getDouble(charIDToTypeID('Gry '));
    break;
  case "RGBC":
    colorObject.rgb.red = colorDesc.getDouble(charIDToTypeID('Rd  '));
    colorObject.rgb.green = colorDesc.getDouble(charIDToTypeID('Grn '));
    colorObject.rgb.blue = colorDesc.getDouble(charIDToTypeID('Bl  '));
    break;
  case "CMYC":
    colorObject.cmyk.cyan = colorDesc.getDouble(charIDToTypeID('Cyn '));
    colorObject.cmyk.magenta = colorDesc.getDouble(charIDToTypeID('Mgnt'));
    colorObject.cmyk.yellow = colorDesc.getDouble(charIDToTypeID('Ylw '));
    colorObject.cmyk.black = colorDesc.getDouble(charIDToTypeID('Blck'));
    break;
  case "LbCl":
    colorObject.lab.l = colorDesc.getDouble(charIDToTypeID('Lmnc'));
    colorObject.lab.a = colorDesc.getDouble(charIDToTypeID('A   '));
    colorObject.lab.b = colorDesc.getDouble(charIDToTypeID('B   '));
    break;
  default:
    return null;
  }
  return colorObject;
};

 

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
Engaged ,
Nov 18, 2020 Nov 18, 2020

Copy link to clipboard

Copied

LATEST

Uaw! it works divinely well SuperMerlin. Thanks for sharing your script.

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 ,
Nov 18, 2020 Nov 18, 2020

Copy link to clipboard

Copied

SuperMerlin is way above my pay grade. You can see the script is complex and his script will only work if the active layer has s single stroke layer style effect.  If there is a second stroke layer effect or more the script will fail with  an error.  You can see when there is a single stroke the script will return what you can see with edit layer style stroke effect.

Capture.jpg

JJMack

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