I've been having a hell of a time with the move layer function, programming a photoshop script in python. Layers are ending up inside of other layer sets rather than after them, etc.
The native command to do this in Photoshop's Javascript is:
layer.move(relativeObject, insertionLocation)
where insertionLocation can be:
ElementPlacement.INSIDE, ElementPlacement.PLACEATBEGINNING, ElementPlacement.PLACEATEND, ElementPlacement.PLACEBEFORE, or ElementPlacement.PLACEAFTER
My current code looks like this:
@staticmethod
def moveLayer(layer, relativeLayer = None, placement = 3):
if placement == PHAPS.ElementPlacementPLACEATEND:
layers = PHAPS.app().ActiveDocument.layers
relativeLayer = layers[len(layers) - 1]
placement = PHAPS.ElementPlacementPLACEAFTER
elif placement == PHAPS.ElementPlacementPLACEATBEGINNING:
relativeLayer = PHAPS.app().ActiveDocument.layers[0]
placement = PHAPS.ElementPlacementPLACEBEFORE
layer.Move(relativeLayer, placement)
And here were my guesses at the values of the constants, which are apparently wrong:
ElementPlacementPLACEATBEGINNING = 1
ElementPlacementINSIDE = 2
ElementPlacementPLACEBEFORE = 3
ElementPlacementPLACEAFTER = 4
ElementPlacementPLACEATEND = 5
I've tried doing a trace on the native values for those constants, but Photoshop does a good job of hiding those. I've also tried Action Manager code, but I'm finding it a bit difficult to understand.
Does anyone know of a dependable way to move layers in photoshop with python? Action Manager code preferred, but not necessary.