Photoshop CS Scripting Guide
76
Scripting Photoshop
Layer objects
3
In Visual Basic and JavaScript you’ll have to duplicate and place the layer. Here’s how:
VB:
Set layerSetRef = docRef.LayerSets.Add
Set layerRef = docRef.ArtLayers(1).Duplicate
layerSetRef,psPlaceAtEnd
layerRef.MoveToEnd layerSetRef
JS:
var layerSetRef = docRef.layerSets.add();
var layerRef = docRef.artLayers[0].duplicate(layerSetRef,
ElementPlacement.PLACEATEND);
layerRef.moveToEnd (layerSetRef);
3.10.3 Linking layers
Scripting also supports linking and unlinking layers. You may want to link layers together so
that moving or transforming them can be done with one statement. To link layers together, do
the following:
AS:
make new art layer in current document with properties {name:"L1"}
make new art layer in current document with properties {name:"L2"}
link art layer "L1" of current document with art layer "L2" of ¬
current document
VB:
Set layer1Ref = docRef.ArtLayers.Add()
Set layer2Ref = docRef.ArtLayers.Add()
layer1Ref.Link layer2Ref.Layer
JS:
var layerRef1 = docRef.artLayers.add();
var layerRef2 = docRef.artLayers.add();
layerRef1.link(layerRef2);