5 Replies Latest reply on Oct 16, 2013 4:38 PM by Trevorׅ

    script for random resizing and applying styles

    e.kessler

      I am looking to reproduce the kids game "Spot It"  for the students in my classroom. http://www.blueorangegames.com/spotit/ I would like to use it for such things as vocabulary. There will be 440 objects, or 220 word pairs.

       

      I would like to automate it as much as possible with data merge and scripts. I will need 3 scripts:

      1. to resize the text frames or images.

      2. to randomly  rotate the frames

      3. to randomly apply either paragraph or object styles.

       

      I have found this to rotate. http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&extid=1234019 I assume this will work on CS5.

      Now I just need the other 2. Any help will be appreciated.

      Thank you,

      Eliezer

        • 1. Re: script for random resizing and applying styles
          Trevorׅ Adobe Community Professional

          Hi Eliezer,

           

          Here's the script for point 3,

           

          var  doc = app.activeDocument, ol, pl, tfl,
                  myObjects = doc.splineItems.everyItem().getElements();
          var   myParas = doc.stories.everyItem().paragraphs.everyItem().getElements();
          var   myTexFrames = doc.textFrames.everyItem().getElements(); // I don't know if you want this
          ol = myObjects.length;
          pl = myParas.length;
          tfl = myTexFrames.length;
          while (ol--) myObjects[ol].appliedObjectStyle = doc.objectStyles.anyItem ();
          while (pl--) myParas[pl].appliedParagraphStyle = doc.paragraphStyles.anyItem ();
          while (tfl--) myTexFrames[tfl].appliedObjectStyle = doc.objectStyles.anyItem ();
          
          

           

          If you want the script for point 1) I'll do it for $10 (paypal) if some else want's to do it for 10 points if not then be in touch if it's worth your while.

           

          Regards Trevor

          • 2. Re: script for random resizing and applying styles
            e.kessler Level 1

            Thank you very much. It works great!

            The only issue is that it some of the text or object frames get no style or if an obejct none or basic applied to them. Is there a way to fix this?

            Thank you again.

            • 3. Re: script for random resizing and applying styles
              Trevorׅ Adobe Community Professional
              var  doc = app.activeDocument, ol, pl, tfl, osl, psl,
                      myObjects = doc.splineItems.everyItem().getElements();
              var   myParas = doc.stories.everyItem().paragraphs.everyItem().getElements();
              var   myTexFrames = doc.textFrames.everyItem().getElements(); // I don't know if you want this
              ol = myObjects.length;
              pl = myParas.length;
              tfl = myTexFrames.length;
              osl = doc.objectStyles.everyItem().getElements().length - 5;
              psl = doc.paragraphStyles.everyItem().getElements().length - 3;
              while (ol--) myObjects[ol].appliedObjectStyle = doc.objectStyles[4 + Math.round (Math.random()*osl)];
              while (pl--) myParas[pl].appliedParagraphStyle = doc.paragraphStyles[2 + Math.round (Math.random()*psl)];
              while (tfl--) myTexFrames[tfl].appliedObjectStyle = doc.objectStyles[4 + Math.round (Math.random()*osl)];
              
              

               

              I put the same fix in for the paragraph styles you can change it back if you like.

               

              Please mark as helpful

               

              Trevor

              1 person found this helpful
              • 4. Re: script for random resizing and applying styles
                e.kessler Level 1

                ~ Trevor ~ wrote:

                 

                Hi Eliezer,

                 

                Here's the script for point 3,

                 

                var  doc = app.activeDocument, ol, pl, tfl,
                        myObjects = doc.splineItems.everyItem().getElements();
                var   myParas = doc.stories.everyItem().paragraphs.everyItem().getElements();
                var   myTexFrames = doc.textFrames.everyItem().getElements(); // I don't know if you want this
                ol = myObjects.length;
                pl = myParas.length;
                tfl = myTexFrames.length;
                while (ol--) myObjects[ol].appliedObjectStyle = doc.objectStyles.anyItem ();
                while (pl--) myParas[pl].appliedParagraphStyle = doc.paragraphStyles.anyItem ();
                while (tfl--) myTexFrames[tfl].appliedObjectStyle = doc.objectStyles.anyItem ();
                 
                

                 

                If you want the script for point 1) I'll do it for $10 (paypal) if some else want's to do it for 10 points if not then be in touch if it's worth your while.

                 

                Regards Trevor

                Are you still available to write that script? How can I get in touch with you for my exact specifications?

                • 5. Re: script for random resizing and applying styles
                  Trevorׅ Adobe Community Professional

                  No problem,

                   

                  Click on the avatar next to my name then click on the "Send private message" option and send me the specifications.

                   

                  Regards

                  Trevor