Notifications
Clear all

[Closed] Get the index of an object's layer

Hi all,

I’m pretty sure this hasn’t been discussed here, I would like to get the index of a layer…

Like a

$.layer.index

Of course it doesn’t work… :wise:

Any idea ?

2 Replies
 lo1

get all layers by index and compare names to the layer you have.

1 Reply
(@groutcho)
Joined: 11 months ago

Posts: 0
 Of course... So obvious. Thanks. Here is the code :
fn getLayerIndex obj = 
 (
 	if (IsValidNode obj) then
 	(		
 		layerList = for i = 0 to layermanager.count-1 collect #( i, (layerManager.getLayer i).name)
 
 		for i = 1 to layerList.count do
 			if (finditem layerList[i] obj.layer.name) != 0 then return layerList[i][1]
 	)
 	
 	else return "Invalid Node"
 )