Copy link to clipboard
Copied
var layer_c = app.activeDocument.layerSets.add();
layer_c.layerSets.add().typename("layera");
How do I name a LayerSet ? What am I doing wrong ?
Copy link to clipboard
Copied
var layer_c = app.activeDocument.layerSets.add();
layer_c.name = 'layera';
Copy link to clipboard
Copied
Hi StrongBeaver,
StrongBeaver wrote:
var layer_c = app.activeDocument.layerSets.add();
layer_c.layerSets.add().typename("layera");
How do I name a LayerSet ? What am I doing wrong ?
Do you want to create and rename a new LayerSet? Or you want to create and rename a new LayerSet which is within a new LayerSet?
Because of:
var layer_c = app.activeDocument.layerSets.add();
This create a new LayerSet which is stored in variable layer_c
layer_c.layerSets.add()
This create a new LayerSet in your LayerSet layer_c. This new Layerset is not stored in a variable.
You can name the second LayerSet like this:
//create a LayerSet
var layer_c = app.activeDocument.layerSets.add();
//create a second LayerSet within the first LayerSet
var layer_c_layerset1 = layer_c.layerSets.add();
//name the second LayerSet
layer_c_layerset1.name = 'layera';
Have fun
Copy link to clipboard
Copied
Last night I looked in the Photoshop DOM Reference guide, including the Adobe Scripting guide after reading the posts and I'm screaming, well not screaming it was late Where do you find the .name property, I'm probably not making much sense in the laste sentence, I hope you can understand what I mean ?
Copy link to clipboard
Copied
The guide is difficult to understand, and a lot of times, I can never get things to work as described in the SDK. I rely a lot on these forums and ps-scripts.com.
Copy link to clipboard
Copied
StrongBeaver wrote:
… Where do you find the .name property …
Scripting is knowledge.
If you haven't the knowledge, scripting is mostly searching for samples and very often trial and error. But if something is possible in the UI often is possible in scripting too.
Also you can do something like this to get the properties:
var layer_c = app.activeDocument.layerSets.add();
alert(layer_c.reflect.properties)
Have fun
Copy link to clipboard
Copied
var yellow = app.activeDocument.layerSets.add();
yellow.LayerKind.LEVELS();
How come an adjustment layer isn't being added to the layerset ?
I've noticed Photoshop is a little slow on creating layerSets and renaming them !
Copy link to clipboard
Copied
If you want to create a levels adjustment layer, use ScriptListner to create the code. With the code you have, you are creating a layer set (group), and you can't change that to an adjustment layer.
Copy link to clipboard
Copied
app.activeDocument.layerSets.add() adds a new layerSet to the document. So yellow would be a layerSet which doesn't have a kind property. You can only set the kind property of artLayers to TEXT( NORMAL is the default ). To add any other layer type you must use Action Manager.
var yellowSet = app.activeDocument.layerSets.add();
yellowSet.name ='Yellow layer set';
newAdjustmentLevelsLayer(undefined,undefined,undefined,126, 255);
app.activeDocument.activeLayer.name = 'My levels layer';
function newAdjustmentLevelsLayer( blackIn, whiteIn, gamma, blackOut, whiteOut ) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( stringIDToTypeID( "adjustmentLayer" ) );
desc.putReference( stringIDToTypeID( "null" ), ref );
var classDesc = new ActionDescriptor();
classDesc.putClass( stringIDToTypeID( "type" ), stringIDToTypeID( "levels" ) );
desc.putObject( stringIDToTypeID( "using" ), stringIDToTypeID( "adjustmentLayer" ), classDesc );
executeAction( stringIDToTypeID( "make" ), desc, DialogModes.NO );
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( stringIDToTypeID( "adjustmentLayer" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ) );
desc.putReference( stringIDToTypeID( "null" ), ref );
var adjustmentDesc = new ActionDescriptor();
var list = new ActionList();
var levelDesc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( stringIDToTypeID( "channel" ), stringIDToTypeID( "channel" ), stringIDToTypeID( "composite" ) );
levelDesc.putReference( stringIDToTypeID( "channel" ), ref );
var inputList = new ActionList();
inputList.putInteger( blackIn!=undefined?blackIn:0 );
inputList.putInteger( whiteIn!=undefined?whiteIn:255 );
levelDesc.putList( stringIDToTypeID( "input" ), inputList );
levelDesc.putDouble(stringIDToTypeID( "gamma" ), gamma!=undefined?gamma:1.0 );
var outputList = new ActionList();
outputList.putInteger( blackOut!=undefined?blackOut:0 );
outputList.putInteger( whiteOut!=undefined?whiteOut:255 );
levelDesc.putList( stringIDToTypeID( "output" ), outputList );
list.putObject( stringIDToTypeID( "levelsAdjustment" ), levelDesc );
adjustmentDesc.putList( stringIDToTypeID( "adjustment" ), list );
desc.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "levels" ), adjustmentDesc );
executeAction( stringIDToTypeID( "set" ), desc, DialogModes.NO );
};