4 Replies Latest reply on Mar 27, 2018 8:57 AM by CarlosCanto

    Script for randomly replacing symbols

    malinn6934325 Level 1

      Hi!

       

      I'm looking for a script that will allow you to select some objects or symbols in your AI-file and then select some of your symbols from the symbols-library in your file and then randomly replace the original objects/symbols with the symbols selected. I have found a few scripts that does basically this but with random replacement of selected colours, transparency or angles but I need one for randomly replacing symbols.

       

      Can someone help?

        • 1. Re: Script for randomly replacing symbols
          Qwertyfly... Level 4

          Try this. it will use all symbols in document.

           

          var doc = app.activeDocument;
          var sym = doc.symbols;
          var sel = doc.selection;
          for(var i = 0; i < sel.length; i++){
              var place = doc.symbolItems.add(sym[Math.floor(Math.random() * sym.length)]);
              place.height = sel[i].height;
              place.width = sel[i].width;
              place.top = sel[i].top;
              place.left = sel[i].left;
              sel[i].remove();
              place.selected = true;
          }
          
          • 2. Re: Script for randomly replacing symbols
            malinn6934325 Level 1

            That works perfectly!!!

            Thanks so much!!!

            • 3. Re: Script for randomly replacing symbols
              elizem60604410 Level 1

              Hi!

               

              I need the exact action to do with a script. But it is my first time using script, how can I install it?

              I tried through extendscript toolkit, but the script doesnt appear in illustrator.

              • 4. Re: Script for randomly replacing symbols
                CarlosCanto Adobe Community Professional & MVP

                try this

                 

                Installing scripts in the Scripts menu

                 

                 

                To include a script in the Scripts menu (File > Scripts), save the script in the Scripts folder, located in the

                /lllustrator CC/Presets folder in your lllustrator CC installation directory, for example C:\Program Files\Adobe\Adobe Illustrator CC 2018\Presets\en_US\Scripts

                .

                The script’s filename, minus

                the file extension, appears in the Scripts menu.

                Scripts that you add to the Scripts folder while Illustrator is running do not appear in the Scripts menu until

                the next time you launch Illustrator.

                Any number of scripts can be installed in the Scripts menu. If you have many scripts, use subfolders in the

                Scripts folder to help organize the scripts in the Scripts menu. Each subfolder is displayed as a separate

                submenu containing the scripts in that subfolder.

                 

                 

                 

                 

                Executing scripts from the Other Scripts menu item

                 

                 

                The Other Scripts item at the end of the Scripts menu (File > Scripts > Other Scripts) allows you to execute

                scripts that are not installed in the Scripts folder.

                Selecting Other Scripts displays a Browse dialog, which you use to navigate to a script file. When you select

                the file, the script is executed.