10 Replies Latest reply on Apr 14, 2017 7:22 AM by norman.sanders

    How to make arrays or repeat objects in circle?

    asturmendez

      Hello,

      1 - How to make arrays without copying and pasting? Fig-1

      2 - how to create objects repeated in circles? Fig-2

       

      Regards and Thanks

      1.png

        • 1. Re: How do these two things?
          c.pfaffenbichler Level 9

          1) Patterns

          2) One option is Scripting (or Actions).

          http://forums.adobe.com/message/3472806#3472806

           

          Edit: That was only for text layers, you could give this a try:

          // xonverts to smart object, copies and rotates a layer;
          // for photoshop cs5 on mac;
          // 2011; use it at your own risk;
          #target photoshop
          ////// filter for checking if entry is numeric and positive, thanks to xbytor //////
          posNumberKeystrokeFilter = function() {
                    this.text = this.text.replace(",", ".");
                    this.text = this.text.replace("-", "");
                    if (this.text.match(/[^\-\.\d]/)) {
                              this.text = this.text.replace(/[^\-\.\d]/g, '');
                              }
                    };
          posNumberKeystrokeFilter2 = function() {
                    this.text = this.text.replace(",", "");
                    this.text = this.text.replace("-", "");
                    this.text = this.text.replace(".", "");
                    if (this.text.match(/[^\-\.\d]/)) {
                              this.text = this.text.replace(/[^\-\.\d]/g, '');
                              };
                    if (this.text == "") {this.text = "2"}
                    if (this.text == "1") {this.text = "2"}
                    };
          ////////////////////////////////////
          var theCheck = photoshopCheck();
          if (theCheck == true) {
          // do the operations;
          var myDocument = app.activeDocument;
          var myResolution = myDocument.resolution;
          var originalUnits = app.preferences.rulerUnits;
          app.preferences.rulerUnits = Units.PIXELS;
          ////////////////////////////////////
          var dlg = new Window('dialog', "set circle-radius for arrangement", [500,300,840,450]);
          // field for radius;
          dlg.radius = dlg.add('panel', [15,17,162,67], 'inner radius');
          dlg.radius.number = dlg.radius.add('edittext', [12,12,60,32], "30", {multiline:false});
          dlg.radius.numberText = dlg.radius.add('statictext', [65,14,320,32], "mm radius ", {multiline:false});
          dlg.radius.number.onChange = posNumberKeystrokeFilter;
          dlg.radius.number.active = true;
          // field for number;
          dlg.number = dlg.add('panel', [172,17,325,67], 'number of copies');
          dlg.number.value = dlg.number.add('edittext', [12,12,60,32], "30", {multiline:false});
          dlg.number.value.onChange = posNumberKeystrokeFilter2;
          dlg.number.value.text = "12";
          // buttons for ok, and cancel;
          dlg.buttons = dlg.add('panel', [15,80,325,130], '');
          dlg.buttons.buildBtn = dlg.buttons.add('button', [13,13,145,35], 'OK', {name:'ok'});
          dlg.buttons.cancelBtn = dlg.buttons.add('button', [155,13,290,35], 'Cancel', {name:'cancel'});
          // show the dialog;
          dlg.center();
          var myReturn = dlg.show ();
          ////////////////////////////////////
          if (myReturn == true) {
          // the layer;
                    var theLayer = smartify(myDocument.activeLayer);
                    app.togglePalettes();
          // get layer;
                    var theName = myDocument.activeLayer.name;
                    var theBounds = theLayer.bounds;
                    var theWidth = theBounds[2] - theBounds[0];
                    var theHeight = theBounds[3] - theBounds[1];
                    var theOriginal = myDocument.activeLayer;
                    var theHorCenter = (theBounds[0] + ((theBounds[2] - theBounds[0])/2));
                    var theVerCenter = (theBounds[1] + ((theBounds[3] - theBounds[1])/2));
          // create layerset;
                    var myLayerSet = myDocument.layerSets.add();
                    theOriginal.visible = false;
                    myLayerSet.name = theName + "_rotation";
          // create copies;
                    var theNumber = dlg.number.value.text;
                    var theLayers = new Array;
                    for (var o = 0; o < theNumber; o++) {
                              var theCopy = theLayer.duplicate(myLayerSet, ElementPlacement.PLACEATBEGINNING);
                              theLayers.push(theCopy);
                              };
          // calculate the radius in pixels;
                    var theRadius = Number(dlg.radius.number.text) / 10 * myResolution / 2.54;
                    myDocument.selection.deselect();
          // get the angle;
                    theAngle = 360 / theNumber;
          // work through the layers;
                    for (var d = 0; d < theNumber; d++) {
                              var thisAngle = theAngle * d ;
                              var theLayer = theLayers[d];
          // determine the offset for outer or inner radius;
                              var theMeasure = theRadius + theHeight/2;
          //                    var theMeasure = theRadius + theWidth/2;
                              var theHorTarget = Math.cos(radiansOf(thisAngle)) * theMeasure;
                              var theVerTarget = Math.sin(radiansOf(thisAngle)) * theMeasure;
          // do the transformations;
                              rotateAndMove(myDocument, theLayer, thisAngle + 90, - theHorCenter + theHorTarget + (myDocument.width / 2), - theVerCenter + theVerTarget + (myDocument.height / 2));
                              };
                    };
          // reset;
          app.preferences.rulerUnits = originalUnits;
          app.togglePalettes()
          };
          ////////////////////////////////////
          ////////////////////////////////////
          ////////////////////////////////////
          ////// function to determine if open document is eligible for operations //////
          function photoshopCheck () {
          var checksOut = true;
          if (app.documents.length == 0) {
                    alert ("no open document");
                    checksOut = false
                    }
          else {
                    if (app.activeDocument.activeLayer.isBackgroundLayer == true) {
                              alert ("please select a non background layer");
                              checksOut = false
                              }
                    else {}
                    };
          return checksOut
          };
          ////// function to smartify if not //////
          function smartify (theLayer) {
          // make layers smart objects if they are not already;
                    if (theLayer.kind != LayerKind.SMARTOBJECT) {
                              myDocument.activeLayer = theLayer;
                              var id557 = charIDToTypeID( "slct" );
                              var desc108 = new ActionDescriptor();
                              var id558 = charIDToTypeID( "null" );
                              var ref77 = new ActionReference();
                              var id559 = charIDToTypeID( "Mn  " );
                              var id560 = charIDToTypeID( "MnIt" );
                              var id561 = stringIDToTypeID( "newPlacedLayer" );
                              ref77.putEnumerated( id559, id560, id561 );
                              desc108.putReference( id558, ref77 );
                              executeAction( id557, desc108, DialogModes.NO );
                              return myDocument.activeLayer
                              };
                    else {return theLayer}
                    };
          ////// radians //////
          function radiansOf (theAngle) {
                    return theAngle * Math.PI / 180
                    };
          ////// rotate and move //////
          function rotateAndMove (myDocument, theLayer, thisAngle, horizontalOffset, verticalOffset) {
          // do the transformations;
          myDocument.activeLayer = theLayer;
          // =======================================================
          var idTrnf = charIDToTypeID( "Trnf" );
              var desc3 = new ActionDescriptor();
              var idFTcs = charIDToTypeID( "FTcs" );
              var idQCSt = charIDToTypeID( "QCSt" );
              var idQcsa = charIDToTypeID( "Qcsa" );
              desc3.putEnumerated( idFTcs, idQCSt, idQcsa );
              var idOfst = charIDToTypeID( "Ofst" );
                  var desc4 = new ActionDescriptor();
                  var idHrzn = charIDToTypeID( "Hrzn" );
                  var idPxl = charIDToTypeID( "#Pxl" );
                  desc4.putUnitDouble( idHrzn, idPxl, horizontalOffset );
                  var idVrtc = charIDToTypeID( "Vrtc" );
                  var idPxl = charIDToTypeID( "#Pxl" );
                  desc4.putUnitDouble( idVrtc, idPxl, verticalOffset );
              var idOfst = charIDToTypeID( "Ofst" );
              desc3.putObject( idOfst, idOfst, desc4 );
              var idAngl = charIDToTypeID( "Angl" );
              var idAng = charIDToTypeID( "#Ang" );
              desc3.putUnitDouble( idAngl, idAng, Number(thisAngle) );
          executeAction( idTrnf, desc3, DialogModes.NO );
          };
          
          1 person found this helpful
          • 2. Re: How do these two things?
            Trevor.Dennis Adobe Community Professional

            Array is one of Autcad's more useful functions, and there have been times when I'd have welcomed its inclusion in Photoshop.  Especially radial arrays.  I know there are work arounds, but that is not the point.

            • 3. Re: How do these two things?
              Noel Carboni Level 8

              Seems to me the Pattern Fill functionality in Photoshop is the way to go, if you're looking for a repeating image...

               

              These pages in the Photoshop Help, for example, give you some info on creating a pattern and filling with it:

               

              http://help.adobe.com/en_US/photoshop/cs/using/WSfd1234e1c4b69f30ea53e41001031ab64-77cea.h tml

               

              http://help.adobe.com/en_US/photoshop/cs/using/WSfd1234e1c4b69f30ea53e41001031ab64-77d2a.h tml

               

              I literally have never done this before but was able to follow the above instructions and in 3 minutes get a pattern fill with arbitrary data.

               

              Pattern.jpg

               

              -Noel

              1 person found this helpful
              • 4. Re: How do these two things?
                asturmendez Level 1

                Thank you all.

                http://www.photoshop-designs.com/foro/viewtopic.php?t=18267

                Tutorial to rotate an object repeatedly. Could serve?

                • 5. Re: How to make arrays or repeat objects in circle?
                  SeveredScion

                  http://mumblyjoe.hubpages.com/hub/Batch-Duplication-in-Photoshop

                   

                  ctrl+alt+t = duplicate and transform. (Doing this to a selection keeps the duplicate on the same layer; having nothing selected duplicates the layer with the transform)

                   

                  ctrl+alt+shift+t = duplicate and repeat previous transformation

                   

                  Can do this repeatedly to make an array. Remember to move the pivot point if you want to rotate around a point that's not the selection's center

                  • 6. Re: How to make arrays or repeat objects in circle?
                    JJMack Most Valuable Participant

                    When you want to repeat something in Photoshop. The first thing that should come to mind is Photoshop automation action scripts fills etc.  All can be use in a automated process. Actions can use scripts, scripts can use actions all can use fills, gradient fills, pattern fills, content aware fills etc.  Patterns also have a size a width and height and can contain transparency.  A pattern may not fill an area precisely which may not be a problem it you just making a temporary grid on a transparent layer. May have a design the may require rotation to get the pattern direction correct for things like framing.

                    [ JJMack ]

                    • 7. Re: How to make arrays or repeat objects in circle?
                      arjun2 Level 1

                      SeveredScion  wrote

                       

                      http://mumblyjoe.hubpages.com/hub/Batch-Duplication-in-Photoshop

                       

                      ctrl+alt+t = duplicate and transform. (Doing this to a selection keeps the duplicate on the same layer; having nothing selected duplicates the layer with the transform)

                       

                      ctrl+alt+shift+t = duplicate and repeat previous transformation

                       

                      Can do this repeatedly to make an array. Remember to move the pivot point if you want to rotate around a point that's not the selection's center

                      This method is great for normal objects. It does not work for smart object. What is the way to radially array a smart object in Photoshop?

                      • 8. Re: How to make arrays or repeat objects in circle?
                        c.pfaffenbichler Level 9

                        Have you tried the Script?

                        • 9. Re: How to make arrays or repeat objects in circle?
                          norman.sanders Adobe Community Professional & MVP

                          Here is a copy of a Step-&-Repeat tech sheet I wrote for my students. You may find it useful.

                           

                          Equally Spaced Duplicate Images

                           

                          heading.jpg

                          To replicate the effect shown above – create equally spaced duplicate images – begin by opening the file containing the master image. Then:

                          1. Open a new file of appropriate size to hold the finished Image. (File > New) 

                           

                          2. Choose the master image file and select the object. In the example above, the Magic Wand was used to select the area surrounding the object and then Select > Inverse to create marching ants around the object.

                           

                          3. Choose the Move tool. Click and drag the object onto the new file and in position it at the left. It will become the start of the row.

                           

                          4. Select the object. Once again, the Magic Wand was used to select the area surrounding the object and then Select > Inverse to create marching ants around the object.

                           

                          5. Hold down Cmd+Opt+Shift and choose Edit > Free Transform. Be sure to release the mouse before releasing the keyboard keys.

                           

                          6. Hold down the Shift key for alignment and drag the framed image to the right. Do not use the center mark in the image when dragging. When dragging you may completely separate this image from the one at the left, or allow it to overlap the one at the left as shown above.  Then key Return. The second image wlll display marching ants.

                           

                          7. Hold down Cmd+Opt+Shift and strike the T key repeatedly. Each time you do, another duplicate will appear, following the spacing you designated. 

                           

                          8. Select > Deselect to remove the marching ants.  Job done.

                           

                          Note that all of the duplicate images appear on one layer.

                           

                           

                          Variations on a theme:

                           

                          composite.jpg

                           

                          To change the duplicate images so that each one in the sequence repeats the adjustment made when the first duplicate was positioned (as seen above): in Step 6, before striking the Return key, drag one of the corner handles diagonally to change the image size, and reposition the image if necessary. Then strike the Return key and follow on to the next step.

                          blue one.jpg

                          To place each duplicate on a separate layer so that each image may be treated differently from the others later, after the technique is complete, skip Step 4.

                           

                          This pinwheel variation is produced this way:

                           

                          1. Open a new file of appropriate size to hold the finished Image. (File > New) 

                           

                          2. Choose the master image file and select the object. In the example above, the Magic Wand was used to select the area surrounding the object and then Select > Inverse to create marching ants around the object.

                           

                          3. Choose the Move tool. Click and drag the object onto the new file and in position near the top, centered (approximately) left and right.

                           

                          4. Select the object. Once again, the Magic Wand was used to select the area surrounding the object and then Select > Inverse to create marching ants around the object.

                           

                          5. Hold down Cmd+Opt+Shift and choose Edit > Free Transform. Be sure to release the mouse before releasing the keyboard keys.

                           

                          6. Hold down the Shift key to ensure a vertical drag and drag the center mark in the image below the object about 1/4”. In the Options Bar set the angle to 30. (Thirty into 360 degrees will produce a 12 image pinwheel.) Then click on the Commit checkmark in the Options bar.

                           

                          7. Hold down Cmd+Opt+Shift and strike the T key repeatedly to complete the circle of images.

                           

                          8. Select > Deselect to remove the marching ants.  Job done.

                          1 person found this helpful
                          • 10. Re: How to make arrays or repeat objects in circle?
                            norman.sanders Adobe Community Professional & MVP

                            I neglected to add this image.

                            pinwheel.jpg