Copy link to clipboard
Copied
i know how to get kind of solid layer
if(_layers[i].kind == LayerKind.SOLIDFILL){
alert("rectangle");
}
but what`s the kind of ellipse (circle shape) i need to make it in alert and thanks for you
This script will test to see if the first anchor point is a corner or rounded, so it will tell if the shapes are possibly a rectangle or an ellipse.
#target photoshop
var doc = activeDocument;
var layPath = doc.pathItems[0].subPathItems[0];
$.writeln(layPath.pathPoints[0].anchor+'===='+layPath.pathPoints[0].leftDirection)
if((layPath.pathPoints[0].anchor[0]===layPath.pathPoints[0].leftDirection[0])&&(layPath.pathPoints[0].anchor[1]===layPath.pathPoints[0].leftDirection[1])){
alert('Shape co
...
Copy link to clipboard
Copied
Unless I am missing something, whether you are adding a solid fill layer or a shape via one of the shape tools, the layer kind is still a LayerKind.SOLIDFILL layer kind.
Perhaps there is a way to get live shape properties or to do complicated math based on vector path co-ordinates...
Copy link to clipboard
Copied
This script will test to see if the first anchor point is a corner or rounded, so it will tell if the shapes are possibly a rectangle or an ellipse.
#target photoshop
var doc = activeDocument;
var layPath = doc.pathItems[0].subPathItems[0];
$.writeln(layPath.pathPoints[0].anchor+'===='+layPath.pathPoints[0].leftDirection)
if((layPath.pathPoints[0].anchor[0]===layPath.pathPoints[0].leftDirection[0])&&(layPath.pathPoints[0].anchor[1]===layPath.pathPoints[0].leftDirection[1])){
alert('Shape could be rectangle')
}
else{alert('Shape could be an ellipse')}
Copy link to clipboard
Copied
Also if the layer bounds does not have a 1:1 Aspect ratio the layers is not a square or a circle.
I also do not know if all solid fill layers are Shape Layers or that all Shape layers are solid fill layers for shapes can have no fill, a gradient fill and a pattern fill as well.
I also do not know Action manager code and when you get layer descriptions using Action manager code the code seems to have a different layerKind list than DOM LayerKind. Its list seem to be like the Layers Palette Kind Filter (Pixel, Adjustment, Text, Shape and Smart Object) + three fill type (Colorfill, Patternfill and Gradientfill) I had map Action Manager layerKind integers different the DOM LayerKind integers.
Copy link to clipboard
Copied
working done.. you are great man
Find more inspiration, events, and resources on the new Adobe Community
Explore Now