12 Replies Latest reply on Jan 22, 2015 1:47 AM by Loic.Aigon

    Is there a plugin or script that will optimize my layout to maximize use of document space?

    Mint Design

      I'm producing labels for museum gallery objects.  We are printing them on adhesive vinyl with peel off back (i'm not sure what the correct term is at the moment).  We pay for the labels by the sheet.  It costs the same whether I get 2 or 6 labels on an 8.5 x 11 sheet.  We get anywhere from 10 to 200+ of these labels print at a time so you can imagine it can be a challenging puzzle to maximize the use of space in order to minimize the wasted space on each sheet.  It is essentially the same issue that people using laser cutters or CNC routers run into.  The material is too expensive to let any real estate go unused unless necessary.

       

      Is anyone aware of a plugin or script that can process a document and move text boxes or objects around to the most economical arrangement possible?  I could also produce these labels in Illustrator if this issue cannot be addressed within InDesign.

       

      Thank you in advance for you advice!

      Brandon

        • 1. Re: Is there a plugin or script that will optimize my layout to maximize use of document space?
          Trevorׅ Adobe Community Professional

          Hi Brandon,

           

          How many labels in total are there to do?

          Are they all rectangular (or square) text frames, If not how you creating them?

          Are they all different sizes or set of 5 or so different sizes?

           

          Trevor

          • 2. Re: Is there a plugin or script that will optimize my layout to maximize use of document space?
            Mint Design Level 1

            Depending on the project, it may just be updating a few labels all the way up to 200+.  Currently I am putting together 3 projects with 25, 60 & 247 labels so it can vary. 

             

            They are rectangular text boxes with a frame around them (cutting line for printer).

             

            The text is of varying length, from 4 - 15 lines of text, this is inherently the obstacle.  If they were all the same size I could choose the best sheet size to maximize coverage.  Below are examples.  See how the page on the left has unused space at the bottom.  I would like a plugin that can search the document for another text box small enough to fit there in order to use the space, like the right page.  Screen Shot 2015-01-13 at 9.27.56 AM.pngScreen Shot 2015-01-13 at 9.28.08 AM.png

            • 3. Re: Is there a plugin or script that will optimize my layout to maximize use of document space?
              Trevorׅ Adobe Community Professional

              Is it safe to asume that only one label can fit across the width and the only variable factor is the height?  At least in the vast majority of cases.

              • 4. Re: Is there a plugin or script that will optimize my layout to maximize use of document space?
                Mint Design Level 1

                90% of the time that would be a safe assumption.  However, if the solution can also involve rotating the labels 90 degrees on its side in order to make use of the sheet width, then yes.  That would be fine. The labels are pre-cut on the sheet and then peeled out. 

                 

                That said, just making the adjustment by height would be a major improvement in economic use of the sheet.

                • 5. Re: Is there a plugin or script that will optimize my layout to maximize use of document space?
                  Peter Kahrel Adobe Community Professional & MVP

                  Google 'space optimization algorithm' and start reading. . .

                  • 6. Re: Is there a plugin or script that will optimize my layout to maximize use of document space?
                    Trevorׅ Adobe Community Professional

                    Hi Peter, Brandon,

                     

                    Unless someone really knows what their doing then note the .... after the start reading on Peters post.

                    To get the most efficient algorithm would cost more in developers time than the savings on the sort of quantities you mentioned. Particularly if considering the page width.

                     

                    I could solve the problem in a very but not most efficient optimization in between 1 and 2 hours.

                    I'm not prepared to do that for free, if you want a quote then send me a private message.

                     

                    The efficiency would obviously be dependent on the sizes of frames you have.

                    For example if you have four frames 2 of 49% and 2 of 51% of the usable page height then you would use 2 pages at 100% coverage

                    If you had 4 frames of 51% then you would end up with 4 pages of 51% coverage .  It would be difficult to deal with that.

                     

                    Realistically speaking one could generally expect a 95%+ coverage with a minimal processing time (less than a sec for 1000 frames) not including the much more significant time it would take to move the frames around the document.

                    For the 20 frame one that might well go down to 85-90%

                     

                    Best of luck,

                     

                    Trevor

                     

                    P.s.  I'll post my algorithm here if you go for it.

                    • 7. Re: Re: Is there a plugin or script that will optimize my layout to maximize use of document space?
                      Trevorׅ Adobe Community Professional

                      Well it look like Brandon lost interest when I mention the word "quote".

                       

                      Either way the basic algorithm is as below.  (lines 19 to 34 - the rest is just for decoration).

                      I might put out a script on my site whenever it comes into existence that would do what Brandon is looking for, it would cost but not too much.

                      This only works for fitting heights it will not make use of the horizontal spacing.

                      To solve that it might be good to use what's know as the Hungarian Algorithm.  I don't have time for that to put it mildly.

                      I've seen the problem referred to as the "Holy Grail" see Re: Is there a script available for arranging elements for optimal use of the printable area?

                       

                      Trevor

                       

                      // "Trevor's Fitting Algorithm" not optimized but considering the speed of the DOM operations that would be need the optimization would be pointless
                      // Generate Random model of Text Frames of a range of heights to be fitted on pages of a given height
                      // By Trevor www.creative-scripts.com (Still not there yet!)
                      var st = +new Date, tt, frameCollection, pageN, a, aa, n, nFames, t, x, pageHeight, pageNumber = 1, safety, minFrameHeight, maxFrameHeight, xx, result;
                      safety = 500; // just in case?
                      nFames = 500; // The smaller this is the higher the fill % will be
                      pageHeight = 210;
                      minFrameHeight = 20; // The smaller this is the higher the fill % will be
                      maxFrameHeight = 160;
                      a = [];
                      frameCollection = [];
                      pageN = [];
                      xx = 0;
                      for (n = 0; n < nFames; n++) {a[n] = ["#" + n ,~~(Math.random() * (maxFrameHeight - minFrameHeight + 1)) + minFrameHeight];}
                      a.sort(function (a,b) {return a[1] < b[1]});
                      aa = a.join(", ");
                      
                      // This is the "Trevor Fitting Algorithm"
                      while (a.length && safety--) {
                      frameCollection =[];
                      t = 0;
                          for (n = 0; a[n] != undefined; n++) {
                              x = a[n][1];
                              if ((t + x) > pageHeight) continue;
                              t += x;
                              frameCollection.push(a[n]);
                              a.splice(n,1);
                              n--;
                          }
                          a.shift();
                          x = ~~(100* t / pageHeight);
                          xx += x;
                      pageN.push("Page [" + pageNumber++ + "] frameCollection: " + frameCollection.join(", ") +
                          " \tHeight Used: " + t + ", " + x + "%")
                      }
                      // Show the Results
                      x = pageN.length;
                      tt = "\nTook " + ((new Date - st)/1000) + " seconds\n";
                      result = "\"Trevor's Fitting Algorithm\" not optimized but considering the speed of the DOM operations that would be need the optimization would be pointless\
                      Generates Random model of Text Frames of a range of heights to be fitted on pages of a given height\
                      By Trevor www.creative-scripts.com (Still not there yet!)\n******************************\
                      A Random Collection of " + nFames + " Text Frames\nHeights Between " +
                      minFrameHeight + " and " +  maxFrameHeight +
                      " Whatchamacallits\nFitted on " + pageNumber +
                      " Pages " + pageHeight + " Whatchamacallits Tall\nAverage Page Filling: " + ~~(xx/x) +
                      "%\nThe # Before the Text Frame Number is it's Index (Would really use ID) this is followed by the Height of The Text Frame" + tt +
                      "These are the Sorted Random Text Frame Heights\n\n" +
                      aa + "\n\n" + pageN.join("\n") +
                      "\n\nLast Page Get's the Left Overs - So Might be Quite a Low % Fill\
                      Average Page Filling: " + ~~(xx/x) + tt;
                      
                      //$.writeln(result);
                      var w = new Window ('dialog', '"Trevor\'s Fitting Algorithm"'),
                          e = w.add('edittext', undefined, result, {multiline: true});
                      /* some fun and games for muti screens */ var sc = $.screens.length, h, wd, c = 0, t; h = ($.screens[0].bottom - $.screens[0].top); wd = ($.screens[0].right - $.screens[0].left); while (sc--) {    t = $.screens[sc].bottom - $.screens[sc].top;    if (t < h) h = t;    t = ($.screens[sc].right - $.screens[sc].left);    if (t < wd) wd = t;};
                      e.preferredSize = [.85 *wd, .85* h];
                      w.show()
                      
                      
                      • 8. Re: Is there a plugin or script that will optimize my layout to maximize use of document space?
                        Loic.Aigon Adobe Community Professional

                        Hi all,

                         

                        Nothing to offer here but just wanted to enter the debate as media optimization is a great interest to me.

                         

                        Looks like a few powerful C libraries exists for imbricating items thus saving media. I once thought of buying one and use the ability to call a c library through extendscript (dll I think on windows, framewok on mac I gues).

                        But I never went further than the idea. Has any of you ever done something like this ?

                         

                        Just curious,

                         

                        Loic

                        • 9. Re: Is there a plugin or script that will optimize my layout to maximize use of document space?
                          Trevorׅ Adobe Community Professional

                          Hi Loic,

                           

                          I got this reply from Kevin Parrott in the thread that I gave the link above.

                           

                          Hi

                           

                          you could look at Plato from Esko as an option, plug in for illustrator.

                           

                          they do charge like a wounded bull though, but they are top notch products

                           

                           

                          http://www.esko.com/en/products/overview/plato/overview/

                           

                          See also http://www.esko.com/en/products/overview/deskpack/overview/

                          and http://www.esko.com/en/~/media/Esko/Files/PDF%20Library/graphic-editors/Graphic_Editors_us .pdf?lang=tr

                          Looks like plato is for windows and power layout for Mac

                           

                          Looks like a wounded bull would charge 135 Euro a month.

                           

                          I've never tried integrating a C library, so I can't help with that.

                           

                          Regards

                           

                          Trevor

                          • 10. Re: Is there a plugin or script that will optimize my layout to maximize use of document space?
                            Loic.Aigon Adobe Community Professional

                            HI Trevor,

                             

                            Esko has great products. They also take advantage of the market providers emptiness regarding to space optimization especially for Illustrator. Hence their prices. But my little finger tells me it may change.

                             

                            Back to the topic, integrating a c library is poorly documented o should I say for  non c developper it's hard to understand how one can call it through ExtendScript. If I break this one day, I fill certainly share my experience

                             

                            However, it my be reachable in ExtendScript. When I look at Marc Autret Wordalizer algorithm, it could certainly be used for space optimization within InDesign. I told him once, I hope he does that one day

                             

                            Good luck to all,

                             

                            Loic

                            • 11. Re: Is there a plugin or script that will optimize my layout to maximize use of document space?
                              TᴀW Adobe Community Professional & MVP

                              I suspect that Marc's Wordalizer has flexibility in adapting the size

                              of the word to the available space -- which is a very different prospect

                              from fitting predefined sizes together optimally. I may be wrong, of course.

                              • 12. Re: Is there a plugin or script that will optimize my layout to maximize use of document space?
                                Loic.Aigon Adobe Community Professional

                                Maybe, I really don't know. What makes me think it could be helpful i when I see it can imbricates words inside letters ( "xxx" in the hole of a o fo ex.).