8 Replies Latest reply on Jan 20, 2017 5:48 AM by studio172

    Make a color hidden.

    studio172 Level 1

      Hello!

      Does anyone know if it's possible to make a color with scripting that doesn't show up in the swatches panel of indesign?

      greetings,

      Stefan

        • 1. Re: Make a color hidden.
          Loic.Aigon Adobe Community Professional

          I ma not sure about that lthough I was told (and checked) that there was (is it still there ?) a bug that when you did something in the swatch panel (maybe add a swatch or something like that), then extra colors were added without showing up. I mean you could have 10 swatches visually in the panel but 12 colors in the collection of colors.

           

          But anyway, I doubt you could reproduce this per scripting (unless I am wrong) but if you intend to use a color only for a temporary purpose, the, you could create it, use it, save/export or whatever operation, then remove the color.

           

          FWIW

           

          Loic

          • 2. Re: Make a color hidden.
            studio172 Level 1

            Yes true, there are hidden colors in the indesign model (indeed more colors in the color-collection than in the swatch-panel)...

             

            The thing is: I was adding a gradient to indesign. To make the colorstops i have to make colors first and then assign them to the colorstops. And now the colorstops show up in the swatches panel (which i don't want... i only want the gradient to show up).

            But if i remove the colors after having completed the gradient, the gradient goes wrong (all colorstops go to black...)

            • 4. Re: Make a color hidden.
              Laubender Adobe Community Professional & MVP

              You could use insertLabel(), extractLabel() for the added unnamed colors to get control by labeling the unnamed colors with a string that could be the substitute for a name value.

               

              Regards,
              Uwe

              • 5. Re: Make a color hidden.
                studio172 Level 1

                Great Uwe!!!

                Thanks a lot! I've been banging my head on this problem for days!

                 

                This does the trick:

                var myUnnamedColor = app.activeDocument.colors[-1].duplicate();

                 

                (kind of strange though... an index of -1?)

                 

                 

                • 6. Re: Make a color hidden.
                  Laubender Adobe Community Professional & MVP

                  No. That's not strange at all. Not with InDesign ExtendScript.

                  Colors is a collection (something like an array) and index number -1 denotes the last element of that collection.

                   

                  Are there alternatives to get what you want?

                  Another way—more cleaner if you want to use a named, but also invisible color—would be to edit an IDML file or even better to edit an exported IDMS snippet (that's easier) with an object that has a fillColor applied.

                   

                  In IDML / IDMS there is the property "Visible" for Color that can be set from "true" to "false". Unfortunately that is not in InDesign's DOM for ExtendScript.

                   

                  With IDML / IDMS if you leave out property "AlternateColor" empty, set "Name" not to an empty string and use "false" as value for "Visible" you could create a snippet, that will import the invisble, named color, if the named color is not already in the document.

                   

                  Regards,
                  Uwe

                  • 7. Re: Make a color hidden.
                    Laubender Adobe Community Professional & MVP

                    studio172 wrote:

                     

                    … This does the trick:

                    var myUnnamedColor = app.activeDocument.colors[-1].duplicate();

                     

                    (kind of strange though... an index of -1?)

                     

                     

                    Hi Stefan,

                    before you get too excited, that would only work if not all unnamed colors were removed.
                    There is a slim chance for that, if e.g. a scripter has played around too much ;-)

                     

                    For a more secure method to add an unnamed color with a dedicated color model—RGB, CMYK or LAB—see my post # 30 in the same thread here where I first add an unnamed color by using different menu commands of the Color panel (not the Swatches panel!):

                     

                    Re: Coloring a Font with a RGB etc. without adding the color to the document swatches.

                     

                    Regards,
                    Uwe

                    1 person found this helpful
                    • 8. Re: Make a color hidden.
                      studio172 Level 1

                      Thanks Uwe! I'll keep that in mind!