// Copyright 2007 SeithCG.com // Name: seithRoundCorners // Purpose: Round the corners of the document. // ---------------------------------------------------------------------------------------------------------- // Get the active document. var docRef = app.activeDocument; // Get the number of layers. var layers = app.activeDocument.artLayers; // Get the number of layers in the doc. If there's more than one, exit. if (layers.length >= 2) { alert('Sorry, this script only works when there is just one layer in the document!', 'Round Corners Script'); } else { // Get the active layer. var activeLayer = docRef.activeLayer; // Duplicate the active layer. var newLayer = activeLayer.duplicate(); // Delete the original active layer. activeLayer.remove(); // ======================================================= // Create the rounded rectangle selection. // ======================================================= var id15 = charIDToTypeID( "setd" ); var desc5 = new ActionDescriptor(); var id16 = charIDToTypeID( "null" ); var ref3 = new ActionReference(); var id17 = charIDToTypeID( "Path" ); var id18 = charIDToTypeID( "WrPt" ); ref3.putProperty( id17, id18 ); desc5.putReference( id16, ref3 ); var id19 = charIDToTypeID( "T " ); var desc6 = new ActionDescriptor(); var id20 = charIDToTypeID( "Top " ); var id21 = charIDToTypeID( "#Pxl" ); desc6.putUnitDouble( id20, id21, -0.000000 ); var id22 = charIDToTypeID( "Left" ); var id23 = charIDToTypeID( "#Pxl" ); desc6.putUnitDouble( id22, id23, -0.000000 ); var id24 = charIDToTypeID( "Btom" ); var id25 = charIDToTypeID( "#Pxl" ); desc6.putUnitDouble( id24, id25, app.activeDocument.height ); var id26 = charIDToTypeID( "Rght" ); var id27 = charIDToTypeID( "#Pxl" ); desc6.putUnitDouble( id26, id27, app.activeDocument.width ); var id28 = charIDToTypeID( "Rds " ); var id29 = charIDToTypeID( "#Pxl" ); desc6.putUnitDouble( id28, id29, 10.000000 ); var id30 = charIDToTypeID( "Rctn" ); desc5.putObject( id19, id30, desc6 ); executeAction( id15, desc5, DialogModes.NO ); // ======================================================= // Select the path created by the rounded rectangle. // ======================================================= var id31 = charIDToTypeID( "setd" ); var desc7 = new ActionDescriptor(); var id32 = charIDToTypeID( "null" ); var ref4 = new ActionReference(); var id33 = charIDToTypeID( "Chnl" ); var id34 = charIDToTypeID( "fsel" ); ref4.putProperty( id33, id34 ); desc7.putReference( id32, ref4 ); var id35 = charIDToTypeID( "T " ); var ref5 = new ActionReference(); var id36 = charIDToTypeID( "Path" ); var id37 = charIDToTypeID( "WrPt" ); ref5.putProperty( id36, id37 ); desc7.putReference( id35, ref5 ); var id38 = charIDToTypeID( "AntA" ); desc7.putBoolean( id38, true ); var id39 = charIDToTypeID( "Fthr" ); var id40 = charIDToTypeID( "#Pxl" ); desc7.putUnitDouble( id39, id40, 0.000000 ); executeAction( id31, desc7, DialogModes.NO ); // ======================================================= // Inverse the selection (basically the rounded corners). // ======================================================= var id41 = charIDToTypeID( "Invs" ); executeAction( id41, undefined, DialogModes.NO ); // ======================================================= // Delete the path. // ======================================================= var id42 = charIDToTypeID( "Dlt " ); executeAction( id42, undefined, DialogModes.NO ); // ======================================================= // Delete the selection. // ======================================================= var id160 = charIDToTypeID( "Dlt " ); executeAction( id160, undefined, DialogModes.NO ); // ======================================================= // Deselect. // ======================================================= var id290 = charIDToTypeID( "setd" ); var desc58 = new ActionDescriptor(); var id291 = charIDToTypeID( "null" ); var ref52 = new ActionReference(); var id292 = charIDToTypeID( "Chnl" ); var id293 = charIDToTypeID( "fsel" ); ref52.putProperty( id292, id293 ); desc58.putReference( id291, ref52 ); var id294 = charIDToTypeID( "T " ); var id295 = charIDToTypeID( "Ordn" ); var id296 = charIDToTypeID( "None" ); desc58.putEnumerated( id294, id295, id296 ); executeAction( id290, desc58, DialogModes.NO ); }