2 Replies Latest reply on Dec 19, 2016 7:29 AM by o-marat

    How to ungroup all swatch groups?

    o-marat Level 3

      Hello!

      Task:

      task.png

      Expected result:

      result.png

      PS. The problem is that it does not impossible - select swatch group on palette swatches via script (to start the ungrouping through action).

      PPS. Or if make duplicate swatches and remove all swatch groups then the document items loose the original colors.

      Thanks!

        • 1. Re: How to ungroup all swatch groups?
          moluapple Level 4

          If all of the swatches in group are pantone spot color, and all are used in document( if not, add some temp path to apply color), steps of the script can be:

          - select all and cut

          - remove all swatch groups except swatchGroups[0]

          - paste in place(remember layers checked on) and swatches will be added automatically.

          1 person found this helpful
          • 2. Re: How to ungroup all swatch groups?
            o-marat Level 3

            The problem turned out to be very simple.

            /**
             * ungroup all swatchGroups
             * */
            function ungrSw() {
              var d        = activeDocument;
              if (activeDocument.swatchGroups.length < 1) return;
              var swGrps   = d.swatchGroups;
              var mainSwGr = d.swatchGroups[0];
              for (var i = 1; i < swGrps.length; i++) { // move swatches to main group
                var swGr    = swGrps[i];
                var swGrSws = swGr.getAllSwatches();
                for (var j = 0; j < swGrSws.length; j++) {
                  var sw = swGrSws[j];
                  mainSwGr.addSwatch(sw);
                }
              }
              for (var k = swGrps.length - 1; k > 0; k--) { // remove empty groups
                var obj = swGrps[k];
                obj.remove();
              }
            }