Yes you should be able to use AM code as a layer has the following keys with Photoshop CS2
AD 01 = name : DescValueType.STRINGTYPE
AD 02 = color : DescValueType.ENUMERATEDTYPE
AD 03 = visible : DescValueType.BOOLEANTYPE
AD 04 = mode : DescValueType.ENUMERATEDTYPE
AD 05 = opacity : DescValueType.INTEGERTYPE
AD 06 = layerID : DescValueType.INTEGERTYPE
AD 07 = itemIndex : DescValueType.INTEGERTYPE
AD 08 = count : DescValueType.INTEGERTYPE
AD 09 = preserveTransparency : DescValueType.BOOLEANTYPE
AD 10 = layerFXVisible : DescValueType.BOOLEANTYPE
AD 11 = globalAngle : DescValueType.INTEGERTYPE
AD 12 = background : DescValueType.BOOLEANTYPE
AD 13 = layerSection : DescValueType.ENUMERATEDTYPE
AD 14 = layerLocking : DescValueType.OBJECTTYPE
AD 15 = group : DescValueType.BOOLEANTYPE
AD 16 = targetChannels : DescValueType.LISTTYPE
AD 17 = visibleChannels : DescValueType.LISTTYPE
AD 18 = channelRestrictions : DescValueType.LISTTYPE
AD 19 = fillOpacity : DescValueType.INTEGERTYPE
AD 20 = bounds : DescValueType.OBJECTTYPE
and here is a code example to get various details including bounds of all layers...
Code: Select allfunction getNamesPlusIDs(){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
var count = executeActionGet(ref).getInteger(charIDToTypeID('NmbL')) +1;
var Names=[];
var doc = activeDocument;
if(doc.layers[doc.layers.length-1].isBackgroundLayer){
var i = 0; }else{ var i = 1; };
for(i;i<count;i++){
if(i == 0) continue;
ref = new ActionReference();
ref.putIndex( charIDToTypeID( 'Lyr ' ), i );
var desc = executeActionGet(ref);
var layerName = desc.getString(charIDToTypeID( 'Nm ' ));
var Id = desc.getInteger(stringIDToTypeID( 'layerID' ));
if(layerName.match(/^<\/Layer group/) ) continue;
var layerType = typeIDToStringID(desc.getEnumerationValue( stringIDToTypeID( 'layerSection' )));
var isLayerSet =( layerType == 'layerSectionContent') ? false:true;
var descBounds = desc.getObjectValue(stringIDToTypeID( "bounds" ));
var Left = descBounds.getUnitDoubleValue(stringIDToTypeID('left'));
var Top = descBounds.getUnitDoubleValue(stringIDToTypeID('top'));
var Right = descBounds.getUnitDoubleValue(stringIDToTypeID('right'));
var Bottom = descBounds.getUnitDoubleValue(stringIDToTypeID('bottom'));
Names.push([[Id],[layerName],[isLayerSet],[Left],[Top],[Right],[Bottom]]);
};
return Names;
};
var layerInfo = getNamesPlusIDs();
for(var a in layerInfo){
$.writeln(layerInfo[a]);
}
Script to delete all empty folders & layers
-
mycort
Script to delete all empty folders & layers
Is this an even faster code for deleting empty layers and folders? Even the second ode version is a bit faster, it still does take a bit of time for more complex and massive psd files with tons of layers/folders......is this only a sample/partial code or is this the complete code that I can try out?
-
Paul MR
Script to delete all empty folders & layers
No, it is just example code that will work for Photoshop CS2 to access all the layer bounds without making the layers active.
-
kostyanet
Script to delete all empty folders & layers
CS2 returns layer bounds by layer ref. Line like doc.activeLayer = layer is not necessary.
I just thought than there is a method to check empty layer without access to its bounds.
I just thought than there is a method to check empty layer without access to its bounds.
-
pfaffenbichler
Script to delete all empty folders & layers
The code in which post are you referring to with »doc.activeLayer = layer«?