Skip to main content
vasxo
Inspiring
February 26, 2015
Question

How to get current layer type (text, art, group layer, etc.)r discussion here

  • February 26, 2015
  • 1 reply
  • 919 views

Hi,

I am traversing over all layers using layerIndex.

I can get current later name in following way.

char* layerName = new char[100];

int32 len = 100;

PIUGetInfoByIndex(layerIndex,classLayer, keyName, layerName , &len) ;

I tried  using the keys keyType and keyGroup in the same way but I am not able to directly get type of the layer. Why?

Also, I found similar discussion, which is check the layer is SectionStart, SectionEnd or SectionContent.

Get Layer Groups from C++ plugin

If the layer is a "SectionContent", how to I further check its type (artlayer, textlater, adjustmentlayer, ect) ?

This topic has been closed for replies.

1 reply

c.pfaffenbichler
Community Expert
Community Expert
February 26, 2015

Sounds like you should post over on the SDK Forum, not on the Scripting Forum after all.

With JavaScript one could do something like this

var ref = new ActionReference();

ref.putProperty(stringIDToTypeID ("property"), stringIDToTypeID("layerKind"));

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

var layerDesc = executeActionGet(ref);

alert (layerDesc.getInteger(stringIDToTypeID("layerKind")));

vasxo
vasxoAuthor
Inspiring
February 26, 2015

apologize !

I post the question in relevant forum. But I would like to ask extra explanation here.

var ref = new ActionReference();                                                                                                              // create action reference

ref.putProperty(stringIDToTypeID ("property"), stringIDToTypeID("layerKind"));                                            // add "layerKind" property to the reference

ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );                   // what putEnumerated actually do ?

var layerDesc = executeActionGet(ref);                                                                                                     // get the corresponding layer descriptor

alert (layerDesc.getInteger(stringIDToTypeID("layerKind")));                                                                       / get its layerKind

1. what putEnumerated actually do ?

2. I am traversing each layer so that I have the layer object in JavaScript.

    How current layer object is refereed to above code segment ?

c.pfaffenbichler
Community Expert
Community Expert
February 26, 2015

The above does only reference the active Layer, I thought that’s what you had meant by "current layer".