Skip to main content
Known Participant
December 30, 2019
Answered

Alert to get below layer name under current later shape

  • December 30, 2019
  • 2 replies
  • 1080 views

i need to make alert for any current layer this alert get below layer name the same example on below image  .. and the same this if current layer shape or text ..and thanks alot 

 

This topic has been closed for replies.
Correct answer Stephen Marsh

I don't know if this is what you are looking for or not... The code is more of a proof of concept than anything:

 

 

var doc = app.activeDocument;
var oLayer = doc.activeLayer;

selectNextVisibleLayer(false);

function selectNextVisibleLayer(makeVisible) {
	var c2t = function (s) {
		return app.charIDToTypeID(s);
	};

	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};

	var descriptor = new ActionDescriptor();
	var list = new ActionList();
	var reference = new ActionReference();

	reference.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("backwardEnum"));
	descriptor.putReference(c2t("null"), reference);
	descriptor.putBoolean(s2t("makeVisible"), makeVisible);
	list.putInteger(3);
	descriptor.putList(s2t("layerID"), list);
	executeAction(s2t("select"), descriptor, DialogModes.NO);
}

var nLayer = doc.activeLayer.name;
doc.activeLayer = oLayer;
alert(nLayer);

 

 

As JJMack noted: "what happens if the lowest layer is selected?"... In the case of this script, the top layer is returned!

2 replies

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
December 30, 2019

I don't know if this is what you are looking for or not... The code is more of a proof of concept than anything:

 

 

var doc = app.activeDocument;
var oLayer = doc.activeLayer;

selectNextVisibleLayer(false);

function selectNextVisibleLayer(makeVisible) {
	var c2t = function (s) {
		return app.charIDToTypeID(s);
	};

	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};

	var descriptor = new ActionDescriptor();
	var list = new ActionList();
	var reference = new ActionReference();

	reference.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("backwardEnum"));
	descriptor.putReference(c2t("null"), reference);
	descriptor.putBoolean(s2t("makeVisible"), makeVisible);
	list.putInteger(3);
	descriptor.putList(s2t("layerID"), list);
	executeAction(s2t("select"), descriptor, DialogModes.NO);
}

var nLayer = doc.activeLayer.name;
doc.activeLayer = oLayer;
alert(nLayer);

 

 

As JJMack noted: "what happens if the lowest layer is selected?"... In the case of this script, the top layer is returned!

Known Participant
December 30, 2019

very good and very excellent ..thanks for you my bro the script working done 

Akash Sharma
Legend
December 30, 2019

Hi there, 

 

Are you referring to the new Layer comp warning alert? If so then, please checkout this article https://helpx.adobe.com/in/photoshop/using/layer-comps.html#clear_layer_comp_warnings and let us know if that helps? 

 

Thanks,

Akash

Known Participant
December 30, 2019

i need to  makes function to get below layer name  not current layer name

JJMack
Community Expert
Community Expert
December 30, 2019

What would trigger that script function to run and receive the lower layer name? What if there is no lower layer.  Also layer names need not be unique there could be many layers with that name in the a document.  Perhaps you want the function to  return the layer object not just the layer name.  It is also possible that more then one layer can be currently targeted.   It is not clear as to what you are trying to do what the function is for.  Getting a layer or layer name is not an alert.   You may want to describe what you want to do. What you want to automate. ???

JJMack