4 Replies Latest reply on Aug 1, 2011 7:03 AM by csm_phil

    Script to create circles

    eliasbobadilla

      Hi!

       

      i need to create a Indesign script to create "bubbles" inside a document like OMR forms (http://www.oocities.org/mingwai_lucky/images/OMR.jpg).

       

      In my document ther is a lot of circles with a letter inside and each circle should be at an exact distance between each. I do this manually, but I want to know how to make a script for InDesign to generate this "bubbles" and do my job easy.

       

      I appreciate any help you can give me

        • 1. Re: Script to create circles
          Shiv_Allva

          Hi,


          You could do:

          1. Create object style with width, rule width, color, etc.,

          2. Script starting with simple dialog getting information like: where the first bubble should start, horizontal and vertical space between bubbles, how many bubbles you want horizontally and vertically

          3. We those information we could running simple loop to create a matrix like bubbles

           

          But for me, we can just go manually, create a first row of bubbles, group it, copy&paste (or ctrl+shift++alt down arrow with modified doc preferences).

           

          Cheers

          Shiv

          • 2. Re: Script to create circles
            2i_Geert

            Something like this should get you started:

             

            var document = app.documents.add();
            var nrOfCircles = 100;
            var nrOfColumns = 10;
            var top = 40;
            var left = 40;
            var width = 20;
            var height = 20;
            var space = 5;

            for (var index = 0; index < nrOfCircles; index++)
            {
                if(index > 0 && index % nrOfColumns == 0)
                {
                    // Reset left
                    left = 40;
                    // Start new row
                    top += height + 5;
                }

                addCircle(index + 1, left, top, left + width, top + height);
                left+= width + space;
            }

             

            function addCircle(number, left, top, right, bottom)
            {
                var circle = document.ovals.add();
                var textFrame = circle.textFrames.add();
                var text = textFrame.texts.firstItem();
               
                circle.geometricBounds = [top, left, bottom, right];
                circle.strokeColor = document.swatches.itemByName("Black");
                circle.strokeWeight = 2;
                textFrame.geometricBounds = [top, left, bottom, right];
               
                text.pointSize = 12;
                text.justification = Justification.CENTER_ALIGN;
                textFrame.textFramePreferences.verticalJustification = VerticalJustification.CENTER_ALIGN;
                textFrame.contents = String(number);
            }

            • 3. Re: Script to create circles
              Shiv_Allva Level 1

              You got it, cool

              • 4. Re: Script to create circles
                csm_phil Level 4

                HI Elias,

                 

                I have one idea to share with you, if you like do this way is very very simple.

                This is the easy way to you achieve your circle placement.

                 

                Steps to be followed:

                1. First you can create the one circle in the inline anchored position with circle properties of color stroke width height and also applied the Object style are you create the object style just.
                2. Next you cut the inline anchored circle.
                3. Use the Find Grep Options to this (10|\b\d\b) this grep only find the 1-10 digits range only.
                4. Change options $1~c.
                5. Please refer the attached snapshot.
                6. After just adjust manually in the circled as you want your position, next you update the redfine style in the Object style.

                 

                Picture 2.png

                 

                 

                I hope you expect i full fill.

                 

                thx

                csm_phil