Code: Select all
	local targetLayer = moho.document:LayerByName("Target")
	if (targetLayer == nil) then
		print("Target layer not found.")
		return
	endModerators: Víctor Paredes, Belgarath, slowtiger
Code: Select all
	local targetLayer = moho.document:LayerByName("Target")
	if (targetLayer == nil) then
		print("Target layer not found.")
		return
	endCode: Select all
local layer= moho.document:LayerByName("Group1")
if (layer == nil) then
    print("Group1 not found.")
    return
end
layer = moho:LayerAsGroup(layer)
layer = layer:LayerByName("Sub-Group2")
if (layer == nil) then
    print("Sub-Group2 not found.")
    return
end
layer = moho:LayerAsGroup(layer)
layer = layer:LayerByName("The Layer I Want")
if (layer == nil) then
    print("The Layer I Want not found.")
    return
end
Code: Select all
local layer = moho.layer  --layer you're on
local parent = LayerAsGroup(layer:Parent()) -- the parent layer if it has one
local target = nil  --where the target goes if you find one
if (parent == nil) then --No parent, so it's a root layer
     target = moho.document:LayerByName("Target")
     if (target == nil) then
          print("Target not found.")
          return
     end 
else
     -- It's inside some "group" type of layer
     target = parent:LayerByName("Target") 
     if (target == nil) then
          print("Target not found.")
          return
     end 
end