0

Having a hard time understanding this method for making imported layers available on the root:

for layerGroupName of PSD
    window[layerGroupName] = PSD[layerGroupName]

for layerGroupName of PSD
    PSD[layerGroupName].originalFrame = window[layerGroupName].frame

What do the original frame and frame methods do, or where are they documented?

nipponese
  • 2,813
  • 6
  • 35
  • 51

1 Answers1

1

this confused me too at first, but I found cues to answer this question in this article by Cemre Güngör.

for layerGroupName of PSD
    window[layerGroupName] = PSD[layerGroupName]

This one copies all the layers from the original object with imported layers to the window object. This way all the layers become available using layerName instead of PSD['layerName'].

for layerGroupName of PSD
    PSD[layerGroupName].originalFrame = window[layerGroupName].frame

frame and originalFrame here are actually keys in an object, not methods. These two lines copy the initial frame (including position of the layer etc.) of each layer under the originalFrame key, so that when you change the position of layers, you can easily revert them to their original position.