8 Replies Latest reply on Aug 9, 2017 6:37 PM by Roy Marshall

    ScriptPreferences Version

    Roy Marshall Level 1

      Hey all

      I dont have a problem I need solving for once, just a question for those in the know.

      In order to get hold of a page item by Label name, I have  a small function which downgrades me to version 6,

      collection.item(label).getElements()

      then putting my version back to the original state.

      This works fine, but has always bothered me using this technique. Will I always be able to rely on switching versions mid-script?

      Are there any other ways that Adobe have introduced that have slipped me by?

      Not a biggie, I was just getting curious, and need to know if I can relax!

       

      Cheers

       

      Royston

        • 1. Re: ScriptPreferences Version
          Laubender Adobe Community Professional & MVP

          Hi Royston,
          you did not mention it, but I'd be surprised if your trick is still working with the latest version of InDesign.
          Cannot contribute much on this, but I would never rely on an older ScriptPreferences Version for a particular feature.

           

          Regards,
          Uwe

          • 2. Re: ScriptPreferences Version
            Roy Marshall Level 1

            Hey Uwe

            Yep, that old trick (That I think Dave Saunders demonstrated) is still working for me in my case.

            so maybe Id better start using more 'proper native' way from now. Such a shame I cannot directly call an item by script label just in case.

            Oh well, onwards and upwards.

             

            Royston

            • 3. Re: ScriptPreferences Version
              Peter Kahrel Adobe Community Professional & MVP

              Roy -- Change script labels to names. Then you can say things like

               

              myPage.textFrames.item('box')

              myDoc.rectangles.item('circle')

               

              It's easy to change labels to names: loop through all page items and

               

              x = app.documents[0].allPageItems;
              for (i = 0; i < x.length; i++) {
                x[i].name = x[i].label;
              }
              

               

              You can see names of page items in the Layers panel.

               

              P.

              1 person found this helpful
              • 4. Re: ScriptPreferences Version
                Roy Marshall Level 1

                Hey Peter.

                 

                That sounds like a fundamental practice I should have been using all along! I did not know that the Name property was available in this way. Seems obvious now though. The Layers panel showing this is pretty useful too.

                 

                Thanks again

                Roy

                • 5. Re: ScriptPreferences Version
                  Laubender Adobe Community Professional & MVP

                  Hm,

                  since item("name") or itemByName("name") will only get the first instance of a named item I see no real advantage in using names instead of labels. But that's for the scripting side of things to collect items with the same label or name value.

                   

                  It's quite different in the UI where the user controls labeling or naming items.

                  Names are more obvious in the Layer Panel than using the Script Label Panel where you have to select item for item to see into the value of the label.

                   

                  Regards,
                  Uwe

                  • 6. Re: ScriptPreferences Version
                    Roy Marshall Level 1

                    There are definitely pros and cons either way. For me, needing this for the sort of work I am doing, I control the name/label allocating, and ensure they are unique, so only selecting the first item works well for me. It appears that the user isn't able to re-name the item in the UI which is another plus point for me.

                    There have been times when I want to collect all items with the same label so I'll be using labels for that purpose.

                    It's good for me to learn different ways, I feel I am not wasting my time so much when I learn a new (to me anyway) technique.

                    Thanks again

                    Roy

                    • 7. Re: ScriptPreferences Version
                      Laubender Adobe Community Professional & MVP

                      https://forums.adobe.com/people/Roy+Marshall  wrote

                      … It appears that the user isn't able to re-name the item in the UI which is another plus point for me.…

                      Roy

                      Hi Roy,

                      but a user would be able to rename a named item in the Layer Panel.


                      And a user would also be able to change the contents of a label in the UI by using the Script Label Panel.
                      Unless you are using insertLabel() / extractLabel() and not using "Label" as key.

                       

                      Regards,
                      Uwe

                      • 8. Re: ScriptPreferences Version
                        Roy Marshall Level 1

                        Hey Uwe.

                         

                        I was just going to say "Where is the edit option" for the Layer item name, when I discovered it. Click, and hover for a second and it becomes editable! Strange there is no menu for this.

                        And I was not aware of the second way to add a label. I use the insertLabel and extractLabel option all the time with pages, and the app itself, but didnt know page items also have this additional layer of labels.

                         

                        I never get bored learning new things!

                         

                        Cheers

                        Roy