6 Replies Latest reply on Sep 27, 2016 11:19 AM by williamadowling

    Create race bib numbers

    theodorel85092388

      I need to do a race bib for a upcoming 5K walkathon. I have a design already but how to create incremental numbers in Illustrator?

        • 1. Re: Create race bib numbers
          zertle Level 2

          Would you happen to have access to InDesign? If so you could use Data Merge to quickly add the numbers :-)

          • 2. Re: Create race bib numbers
            williamadowling Level 4

            how many numbers will you ultimately need? 3, 4 or 5 digits? do you want to "zero fill" the numbers? For example, if you need 5000 bibs, you'll have 4 digits max. do you want the lower number bibs to say "0043" or just "43"?

             

            do you have a sample file we could look at so i can be sure i'm getting you something relevent?

            • 3. Re: Create race bib numbers
              williamadowling Level 4

              Ok, so I just went ahead and made a couple of assumptions to get you something to start with. This could be easily edited to fit your needs.

               

              The assumptions:

              a template file that contains the following layer structure:

              Screen Shot 2016-09-20 at 1.35.00 PM.jpg

              Main Bib is the top level, container layer that will hold all subsequent bib numbers.

              Bib Number is a temporary layer with which we will model the other sublayers.

              0000 is simply a text frame inside of the Bib Number layer.

              *Note* the screenshot shows 4 digits, 0000, but the code below does not zero fill. It will simply input the sequence number.

               

              The code:

              function incrementBib()
              {
                  var docRef = app.activeDocument;
                  var layers = docRef.layers;
              
                  //min and max variables below can be used in order to create separate files in 
                  //case there are an exorbitant amount of bib numbers needed. For example:
                  //if you need 10,000 bibs, you would end up with 10,000 sublayers in your document
                  //which could cause issues. So perhaps you wanted to split the file into 10 files
                  //with 1000 bibs each, you could enter 6001 as the minimum and 7000 as the max. Then
                  //save your file and re-open the template and run the script again with min=7001 and max=8000
                  //etc.
              
                  var min = 1; //change this value to the lowest number you want
                  var max = 10; //change this value to the highest
              
              
                  var main = layers["Main Bib"];
                  var tmp = main.layers["Bib Number"]; //this is a temporary sublayer and will be removed at the end of execution
                  var tmpTxt = tmp.textFrames[0];
                  for(var b=max;b>min-1;b--)
                  {
                      var thisBib = main.layers.add();
                      thisBib.name = "Bib Number " + b
                      var thisNum = tmpTxt.duplicate(thisBib);
                      thisNum.contents = b;
              
                  }
                  tmp.remove();
              }
              incrementBib();
              

               

               

              The result:

              A file with one main 'container' layer called "Main Bib".

              1 individual sub layer per sequence number named "Bib Number #"

                   each sublayer contains a single text frame whose contents are the sequence number.

              Screen Shot 2016-09-20 at 1.50.28 PM.jpg

               

              The next step:

              Another function can be written to hide all of the layers, then unhide each layer, 1 at a time and export a print file to the desired location.

              • 4. Re: Create race bib numbers
                theodorel85092388 Level 1

                Can I have step by step tutorial?

                • 5. Re: Create race bib numbers
                  williamadowling Level 4

                  Do you have any programming experience?

                   

                  This is relatively basic, but without some cursory knowledge of programming logic it probably just looks like gibberish.

                   

                  I'll go through line by line and talk about what's happening.

                   

                   

                  function incrementBib()  //this is a container function just to keep variables local
                  {  
                      var docRef = app.activeDocument;  //the currently active document
                      var layers = docRef.layers;  //an array of all the layers in the document
                    
                      //min and max variables below can be used in order to create separate files in   
                      //case there are an exorbitant amount of bib numbers needed. For example:  
                      //if you need 10,000 bibs, you would end up with 10,000 sublayers in your document  
                      //which could cause issues. So perhaps you wanted to split the file into 10 files  
                      //with 1000 bibs each, you could enter 6001 as the minimum and 7000 as the max. Then  
                      //save your file and re-open the template and run the script again with min=7001 and max=8000  
                      //etc.  
                    
                  
                      //var min indicates the lowest number bib that should be created
                      var min = 1; //change this value to the lowest number you want  
                      
                  
                      //var max indicates the highest number
                      var max = 10; //change this value to the highest  
                    
                      //the script will generate one sublayer and one text frame for each integer in between min and max
                    
                      var main = layers["Main Bib"];  //this is saying "go to the layers array, and get me the layer called 'Main Bib'"
                                                      //'Main Bib' can be any text you like. Just make sure there's a layer with the corresponding name.
                  
                      
                      var tmp = main.layers["Bib Number"]; //this is a temporary sublayer and will be removed at the end of execution  
                                                           //this line means "inside the layer 'Main Bib', (var main), give me the layer called 'Bib Number', 
                      
                  
                      var tmpTxt = tmp.textFrames[0];  //this line says "inside the layer 'Bib Number' (var tmp), find me the first instance of a textFrame" (zero based index, so zero means 1).
                                                       //You can also find a text frame by name, just like in the layers examples above.
                      
                  
                      for(var b=max;b>min-1;b--)  // this loop executes once for each bib number you need. the difference between min and max
                      {  
                          var thisBib = main.layers.add();  // Here we are adding a new layer to the 'main' layer.
                      
                  
                          thisBib.name = "Bib Number " + b;  //Here we are setting the name of this layer to the string "Bib Number " 
                                                             //and then appending the variable "b" which is an integer between min and max.
                      
                  
                          var thisNum = tmpTxt.duplicate(thisBib);  //this line duplicates the text frame from the 'tmp' layer and sends it to the new layer we created, (var thisBib);
                      
                  
                          thisNum.contents = b;  //Here, we change the contents of the textFrame to the current number in the sequence, represented by 'b'.
                    
                      }  
                      tmp.remove();  //Lastly, remove the tmp layer so that you are left only with the correct bib number layers.
                  }  
                  incrementBib();   //call the container function incrementBib() to begin execution
                  
                  • 6. Re: Create race bib numbers
                    williamadowling Level 4

                    Were you able to get this to work? Did you need any more help?