13 Replies Latest reply on Apr 4, 2017 5:03 AM by haim6130

    Auto replace text with an object

    haim6130

      Hi!

       

      I have a text frame, and I want to make the following:

      1. When I insert "0", the character will be replaced automatically  with object one (like in the attached image)

      2. When I insert "+", the character will be replaced automatically  with object two (like in the attached image)

      3. When I insert "-", the character will be replaced automatically with object three (like in the attached image)

       

      How can I do this?

      I have Windows 7 & Indesign CS5.5

       

      Thanks!

       

      Untitled-7.jpg

        • 1. Re: Auto replace text with an object
          BarbBinder Adobe Community Professional

          We'll see what the scripting folks come up with. For me, as a non-scripter, I would handle this as a Find/Change*. Obviously not automatic, but you can save the query as run as needed.

           

          1. Select the first image and copy it
          2. Find what: 0
          3. Change to: Other > Clipboard Contents, Unformatted

          InDesign CCss_024.png

          * I don't remember when InDesign introduced this option. I think it was in 5.5 but it is possible it isn't.

           

          Edit: Aman's article—which shows the same procedure—is dated 2008, so that means that Change to Clipboard Contents is in CS5.5. which was released in 2010.

          1 person found this helpful
          • 2. Re: Auto replace text with an object
            amaarora Adobe Employee

            Hi,

            You can refer to this interesting article on InDesign Secrets page.

            https://indesignsecrets.com/find-text-change-to-graphic.php

            This might be helpful in some way.

            -Aman

            1 person found this helpful
            • 3. Re: Auto replace text with an object
              haim6130 Level 1

              Hi guys, and thanks for your fast answers!

               

              I've tried the 'Find & Change' (I've been visited already in that InDesign Secrets link),

              but as I said I need it to done automatically.

               

              Maybe you'll know some script for that? Thanks a lot!

              • 4. Re: Auto replace text with an object
                Laubender Adobe Community Professional & MVP

                Hi,
                create your own font with the three symbols.

                Then you fomat your 0, +, - accordingly.

                 

                Have a GREP Style in the applied paragraph style to automatically apply the right size and fill color together with the right font.

                 

                There is the IndyFont script by Jongware and Marc Autret that can do what you want.
                The demo version is able to create one-glyph fonts:

                Indiscripts :: IndyFont

                 

                 

                Regards,
                Uwe

                1 person found this helpful
                • 5. Re: Auto replace text with an object
                  Willi Adelberger Most Valuable Participant

                  Uwe, that is correct, but in the most cases when someone wants to replace a letter to an image, it is either multi color or it is a rasterized drawing, like from a candle, a hand or something else. I think the symbols in the questions are only simplified images to make us understand the question.

                   

                  But I agree, I create also my own fonts to perform these tasks. I use either Fontographer or FontLab, both are dedicated font creation applications. And even, if I have multi color drawings it is made possible as you can create several overlapping glyphs where each of them has a different color and the result is a multicolor drawing in the text. The only disadvantage is, I cannot automate it in lists, but I can automate it with GREP or with nested styles.

                  • 6. Re: Auto replace text with an object
                    haim6130 Level 1

                    Thanks guys!

                     

                    I'll try the font-changing & the indyfont script. thanks!

                    • 7. Re: Auto replace text with an object
                      Laubender Adobe Community Professional & MVP

                      Hi,

                      watch the available movies about IndyFont first. Then read the documentation before doing anything.

                      Even if you used a font editor or a font creation tool before. The time spent will pay off.

                       

                      When creating a font to solve problems like these keep in mind, that the base shape of the glyph is always monochrome only.

                      All formatting is done through InDesign's text formatting capabilities. The new multi-color font technology is not supported with InDesign.

                       

                      Regards,
                      Uwe

                      • 8. Re: Auto replace text with an object
                        Laubender Adobe Community Professional & MVP

                        https://forums.adobe.com/people/Willi+Adelberger  wrote

                        … I think the symbols in the questions are only simplified images to make us understand the question. …

                        Hi Willi,

                         

                        even if they are images, I think—or at least I hope—they are not "simplified". They can be easily drawn as vector shapes and compound paths in InDesign. And because they are all monochrome they are ideal candidates for glyph creation with IndyFont.

                         

                        Regards,
                        Uwe

                        • 9. Re: Auto replace text with an object
                          haim6130 Level 1

                          Hi guys,

                           

                          I found this script that do the job:

                          https://www.rorohiko.com/wordpress/2014/06/24/peoples-choice-indesign-script-pepcon-2014-r eplace-words-images-vice-versa…

                           

                          but I'm facing a new problem.

                          I need to swap the characters '+', '-' and '0', but the script stopping Indesign and not working.

                          With letters it works just fine, but I have it to be  '+', '-' and '0'.

                          The script now looks like this:

                           

                          baseFolder = "p:\\grafim\\bursa\\pas\\icons"

                           

                           

                          ++

                          text = "\\b-\\b"

                          imageName = "d.eps"

                          caseSensitive = 0

                           

                          ++

                          text = "\\b+\\b"

                          imageName = "u.eps"

                           

                          ++

                          text = "\\b0\\b"

                          imageName = "n.eps"

                           

                           

                          What can I do to solve the problem?

                          Thanks!

                          Haim

                          • 10. Re: Auto replace text with an object
                            vinny38 Level 4

                            Here's another workaround, based on a combination of Autocorrect feature + Grep styles

                             

                            1- create a paragraph style based on some exotic language you'll probably never use. (Lithuanian in my example)

                            2- Open the Autocorrect/Lithuanian.xml file.

                            To locate the correct autocorrect xml file, find your Scripts panel in InDesign. In the panel you’ll see a “User” folder. Right-click or Control-click on this folder, and choose Reveal in Finder/Reveal in Explorer. In the folder that appears, navigate up the folder tree 2 levels. You should see a folder named after your locale (mine is named “fr_FR”). In this folder you’ll see a folder named Autocorrect, and in this folder is the lihuanian XML file we need to edit.

                             

                            3- Edit the XML as for autocorrection. Use Unicodes pattern as the example below:

                             

                            <?xml version="1.0" encoding="UTF-16" standalone="yes"?>
                            <autocorrect>
                              <language name="Lithuanian" />
                              <wordpairs>
                              <wordpair misspelled="0" corrected="&#xF098;&#xF0A1;" /> <!-- Zero change to circle (wingdings2) + square (wingdings2)-->
                              <wordpair misspelled="&#x002D;" corrected="&#xF098;&#xF081;" /> <!-- Minus change to circle (wingdings2) + down triangle (wingdings3)-->
                              <wordpair misspelled="&#x002B;" corrected="&#xF098;&#xF082;" /> <!-- Plus change to circle (wingdings2) + up arrow (wingdings3)-->
                              </wordpairs>
                            </autocorrect>
                            

                             

                            4- Restart indesign. Go preferences and enable Autocorrect > Lithuanian

                             

                            5- Create character styles for your 6 symbols: grey circle, red circle, green circle, square (Wingdings 2), up and down triangles (wingdings 3). Adjust approach for square and triangles in order to place them on top of circle...

                             

                            6- Edit your paragraph styles and set up GREP styles in order to apply relevant character styles to each symbol

                             

                            7-Here you go, apply your para style and just type 0, + or - (followed by a space, return, or punctuation) and it should create your symbol automatically.

                            Please note I haven't tested it

                            1 person found this helpful
                            • 11. Re: Auto replace text with an object
                              Laubender Adobe Community Professional & MVP

                              Hi Haim,

                              I think, you are better off doing your own font. :-)
                              Even if you'd have to build three one-glyph fonts with the demo version of IndyFont.

                               

                              Still, If you want to follow the route with that script contact the script's author, Kris of rorohiko.

                              You also can send him a private message through the Adobe forum:

                              RorohikoKris

                               

                              Regards,
                              Uwe

                              • 12. Re: Auto replace text with an object
                                RorohikoKris Level 2

                                Swimmer uses GREP expressions.

                                 

                                The '+' has special meaning to GREP, and it must be escaped to be treated as a normal character.

                                 

                                So you need to do:

                                 

                                ...

                                text = "\\b\\+\\b"

                                ...

                                1 person found this helpful
                                • 13. Re: Auto replace text with an object
                                  haim6130 Level 1

                                  Many thanks !