レイヤーを移動させる

■プログラム説明
 レイヤーを移動させるにはtranslate(横移動量, 縦移動量)を使います。移動量は正数、負数を指定することができます。移動量なので指定した座標に移動するわけではありません。レイヤーオブジェクトは参照番号または名前で指定することができます。

■ソースコード
activeDocument.activeLayer.translate(50,-30);
activeDocument.artLayers[0].translate(10,-20);
activeDocument.artLayers["textLayer"].translate(30,20);

■ポイント
 全てのレイヤー(背景を除く)をランダムに移動させるには以下のようになります。

docObj = activeDocument.artLayers;
for (i=0; i<docObj.length; i++)
{
if (!docObj[i].isBackgroundLayer)
{
dx = Math.random() * 100 -50;
dy = Math.random() * 100 -50;
docObj[i].translate(dx,dy);
}
}