How to get the length of artLayers?

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

yangcin

How to get the length of artLayers?

Post by yangcin »

How to get the length of ArtLayer?
There is 1 artLayer added.we need the artLayer to position the end of the artlyer

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

How to get the length of artLayers?

Post by Mike Hale »

There are three collection for layers. They are layers, artLayers, and layerSets. Layers contain both artLayers and layerSets. The other two only contain layers of that kind. There is a set of collections for each level in the layers panel.

So to find the number of artLayers at the top or document level you would use app.activeDocument.artLayers.length. It takes a little more work using Action Manager if you want to collect all the artLayers regardless of how they are nested in layerSets.
yangcin

How to get the length of artLayers?

Post by yangcin »

Mike Hale wrote:There are three collection for layers. They are layers, artLayers, and layerSets. Layers contain both artLayers and layerSets. The other two only contain layers of that kind. There is a set of collections for each level in the layers panel.

So to find the number of artLayers at the top or document level you would use app.activeDocument.artLayers.length. It takes a little more work using Action Manager if you want to collect all the artLayers regardless of how they are nested in layerSets.

Thanks too much! Mike
yangcin

How to get the length of artLayers?

Post by yangcin »

Mike Hale wrote:There are three collection for layers. They are layers, artLayers, and layerSets. Layers contain both artLayers and layerSets. The other two only contain layers of that kind. There is a set of collections for each level in the layers panel.

So to find the number of artLayers at the top or document level you would use app.activeDocument.artLayers.length. It takes a little more work using Action Manager if you want to collect all the artLayers regardless of how they are nested in layerSets.

Hi, Mike , the layer.kind = text. how to get length?
yangcin

How to get the length of artLayers?

Post by yangcin »

For example:

var msgLayer = app.activeDocument.artLayers.add();
msgLayer.kind = LayerKind.TEXT;
msgLayer.textItem.Justification.LEFT
msgLayer.textItem.contents = '..........';
msgLayer.textItem.font = ....
msgLayer.textItem.size = .....

How to get the length of msgLayer?
Mike Hale

How to get the length of artLayers?

Post by Mike Hale »

There is not a length property for text layers. What you can do is get the textLayer.contents property which is a string then use the string.length property to determine the number of charters is the contents.

msgLayer.textItem.contents.length;// uses the String.length property