Chuck Uebele escreveu Try this: #target photoshop var row = 3; var column = 3; if(app.documents.length>0){ var doc = activeDocument; try{ var sBounds = doc.selection.bounds; var sWidth = (parseFloat(sBounds[2]) -parseFloat(sBounds[0]))/column; var sHeight = (parseFloat(sBounds[3]) -parseFloat(sBounds[1]))/row; var leftSide = parseFloat (sBounds[0]); var topSide = parseFloat (sBounds[1]); for(var i=0;i<row;i++){ leftSide = parseFloat (sBounds[0]); for(var j=0;j<column;j++){ Create_Rectangle (topSide, leftSide, topSide + sHeight, leftSide + sWidth) leftSide += sWidth } topSide += sHeight } }//end try catch(e){alert('There is no selection')} } else{alert('There are no open documents')} function Create_Rectangle(top,left,bottom,right) { var idMk = charIDToTypeID( "Mk " ); var desc14 = new ActionDescriptor(); var idnull = charIDToTypeID( "null" ); var ref4 = new ActionReference(); var idcontentLayer = stringIDToTypeID( "contentLayer" ); ref4.putClass( idcontentLayer ); desc14.putReference( idnull, ref4 ); var idUsng = charIDToTypeID( "Usng" ); var desc15 = new ActionDescriptor(); var idType = charIDToTypeID( "Type" ); var desc16 = new ActionDescriptor(); var idClr = charIDToTypeID( "Clr " ); var desc17 = new ActionDescriptor(); var idRd = charIDToTypeID( "Rd " ); desc17.putDouble( idRd, 0.000000 ); var idGrn = charIDToTypeID( "Grn " ); desc17.putDouble( idGrn, 0.000000 ); var idBl = charIDToTypeID( "Bl " ); desc17.putDouble( idBl, 0.000000 ); var idRGBC = charIDToTypeID( "RGBC" ); desc16.putObject( idClr, idRGBC, desc17 ); var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" ); desc15.putObject( idType, idsolidColorLayer, desc16 ); var idShp = charIDToTypeID( "Shp " ); var desc18 = new ActionDescriptor(); var idunitValueQuadVersion = stringIDToTypeID( "unitValueQuadVersion" ); desc18.putInteger( idunitValueQuadVersion, 1 ); var idTop = charIDToTypeID( "Top " ); var idPxl = charIDToTypeID( "#Pxl" ); desc18.putUnitDouble( idTop, idPxl, top ); var idLeft = charIDToTypeID( "Left" ); var idPxl = charIDToTypeID( "#Pxl" ); desc18.putUnitDouble( idLeft, idPxl, left ); var idBtom = charIDToTypeID( "Btom" ); var idPxl = charIDToTypeID( "#Pxl" ); desc18.putUnitDouble( idBtom, idPxl, bottom ); var idRght = charIDToTypeID( "Rght" ); var idPxl = charIDToTypeID( "#Pxl" ); desc18.putUnitDouble( idRght, idPxl, right ); var idtopRight = stringIDToTypeID( "topRight" ); var idPxl = charIDToTypeID( "#Pxl" ); desc18.putUnitDouble( idtopRight, idPxl, 0.000000 ); var idtopLeft = stringIDToTypeID( "topLeft" ); var idPxl = charIDToTypeID( "#Pxl" ); desc18.putUnitDouble( idtopLeft, idPxl, 0.000000 ); var idbottomLeft = stringIDToTypeID( "bottomLeft" ); var idPxl = charIDToTypeID( "#Pxl" ); desc18.putUnitDouble( idbottomLeft, idPxl, 0.000000 ); var idbottomRight = stringIDToTypeID( "bottomRight" ); var idPxl = charIDToTypeID( "#Pxl" ); desc18.putUnitDouble( idbottomRight, idPxl, 0.000000 ); var idRctn = charIDToTypeID( "Rctn" ); desc15.putObject( idShp, idRctn, desc18 ); var idstrokeStyle = stringIDToTypeID( "strokeStyle" ); var desc19 = new ActionDescriptor(); var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" ); desc19.putInteger( idstrokeStyleVersion, 2 ); var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" ); desc19.putBoolean( idstrokeEnabled, true ); var idfillEnabled = stringIDToTypeID( "fillEnabled" ); desc19.putBoolean( idfillEnabled, true ); var idstrokeStyleLineWidth = stringIDToTypeID( "strokeStyleLineWidth" ); var idPxl = charIDToTypeID( "#Pxl" ); desc19.putUnitDouble( idstrokeStyleLineWidth, idPxl, 1.000000 ); var idstrokeStyleLineDashOffset = stringIDToTypeID( "strokeStyleLineDashOffset" ); var idPnt = charIDToTypeID( "#Pnt" ); desc19.putUnitDouble( idstrokeStyleLineDashOffset, idPnt, 0.000000 ); var idstrokeStyleMiterLimit = stringIDToTypeID( "strokeStyleMiterLimit" ); desc19.putDouble( idstrokeStyleMiterLimit, 100.000000 ); var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" ); var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" ); var idstrokeStyleButtCap = stringIDToTypeID( "strokeStyleButtCap" ); desc19.putEnumerated( idstrokeStyleLineCapType, idstrokeStyleLineCapType, idstrokeStyleButtCap ); var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" ); var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" ); var idstrokeStyleMiterJoin = stringIDToTypeID( "strokeStyleMiterJoin" ); desc19.putEnumerated( idstrokeStyleLineJoinType, idstrokeStyleLineJoinType, idstrokeStyleMiterJoin ); var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" ); var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" ); var idstrokeStyleAlignInside = stringIDToTypeID( "strokeStyleAlignInside" ); desc19.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, idstrokeStyleAlignInside ); var idstrokeStyleScaleLock = stringIDToTypeID( "strokeStyleScaleLock" ); desc19.putBoolean( idstrokeStyleScaleLock, false ); var idstrokeStyleStrokeAdjust = stringIDToTypeID( "strokeStyleStrokeAdjust" ); desc19.putBoolean( idstrokeStyleStrokeAdjust, false ); var idstrokeStyleLineDashSet = stringIDToTypeID( "strokeStyleLineDashSet" ); var list2 = new ActionList(); desc19.putList( idstrokeStyleLineDashSet, list2 ); var idstrokeStyleBlendMode = stringIDToTypeID( "strokeStyleBlendMode" ); var idBlnM = charIDToTypeID( "BlnM" ); var idNrml = charIDToTypeID( "Nrml" ); desc19.putEnumerated( idstrokeStyleBlendMode, idBlnM, idNrml ); var idstrokeStyleOpacity = stringIDToTypeID( "strokeStyleOpacity" ); var idPrc = charIDToTypeID( "#Prc" ); desc19.putUnitDouble( idstrokeStyleOpacity, idPrc, 100.000000 ); var idstrokeStyleContent = stringIDToTypeID( "strokeStyleContent" ); var desc20 = new ActionDescriptor(); var idClr = charIDToTypeID( "Clr " ); var desc21 = new ActionDescriptor(); var idRd = charIDToTypeID( "Rd " ); desc21.putDouble( idRd, 121.991998 ); var idGrn = charIDToTypeID( "Grn " ); desc21.putDouble( idGrn, 121.991998 ); var idBl = charIDToTypeID( "Bl " ); desc21.putDouble( idBl, 121.991998 ); var idRGBC = charIDToTypeID( "RGBC" ); desc20.putObject( idClr, idRGBC, desc21 ); var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" ); desc19.putObject( idstrokeStyleContent, idsolidColorLayer, desc20 ); var idstrokeStyleResolution = stringIDToTypeID( "strokeStyleResolution" ); desc19.putDouble( idstrokeStyleResolution, 300.000000 ); var idstrokeStyle = stringIDToTypeID( "strokeStyle" ); desc15.putObject( idstrokeStyle, idstrokeStyle, desc19 ); var idcontentLayer = stringIDToTypeID( "contentLayer" ); desc14.putObject( idUsng, idcontentLayer, desc15 ); var idLyrI = charIDToTypeID( "LyrI" ); desc14.putInteger( idLyrI, 27 ); executeAction( idMk, desc14, DialogModes.NO ); }; Hi Chuck Uebele How can we add in your script a space of 15 px between all rows and columns ?? Create the variable = "spaceSize": spaceSize = 15; Congratulations on the script! Thank you
... View more