// Copyright 2007 SeithCG.com // Name: seithFlip // Purpose: Flip the current horizontaly in a "smart way": // - if the selected layer is in a group, flip every layers in the group // - if the selected layer is not in a group, only flip the selected layer(s) // ---------------------------------------------------------------------------------------------------------- // Get the active document. var docRef = app.activeDocument; // Get the active layer. var activeLayer = docRef.activeLayer; // Get the parent of the active layer. var activeLayerParent = activeDocument.activeLayer.parent; //alert("Document name= " + docRef.name + "\nThe first layer= " + activeLayer + "\nLayer name= " + activeLayer.name + "\nParent LayerSet name is: " + activeLayerParent.name ); // Select the parent layerSet if it exists. if (activeLayerParent.name != docRef.name) docRef.activeLayer = docRef.layerSets[activeLayerParent.name]; /* else { // ======================================================= // Select similar layers // ======================================================= var id294 = stringIDToTypeID( "selectSimilarLayers" ); var desc74 = new ActionDescriptor(); var id295 = charIDToTypeID( "null" ); var ref53 = new ActionReference(); var id296 = charIDToTypeID( "Lyr " ); var id297 = charIDToTypeID( "Ordn" ); var id298 = charIDToTypeID( "Trgt" ); ref53.putEnumerated( id296, id297, id298 ); desc74.putReference( id295, ref53 ); executeAction( id294, desc74, DialogModes.NO ); // ======================================================= } */ // ======================================================= // Flip the layer(s) horizontaly // ======================================================= var id299 = charIDToTypeID( "Flip" ); var desc75 = new ActionDescriptor(); var id300 = charIDToTypeID( "null" ); var ref54 = new ActionReference(); var id301 = charIDToTypeID( "Lyr " ); var id302 = charIDToTypeID( "Ordn" ); var id303 = charIDToTypeID( "Trgt" ); ref54.putEnumerated( id301, id302, id303 ); desc75.putReference( id300, ref54 ); var id304 = charIDToTypeID( "Axis" ); var id305 = charIDToTypeID( "Ornt" ); var id306 = charIDToTypeID( "Hrzn" ); desc75.putEnumerated( id304, id305, id306 ); executeAction( id299, desc75, DialogModes.NO ); // ======================================================= // Select the original layer(s) back. if (activeLayerParent.name != docRef.name) docRef.activeLayer = docRef.layerSets[activeLayerParent.name].layers[activeLayer.name]; else docRef.activeLayer = docRef.layers[activeLayer.name];