4

Is it possible to resize a group of shapes and keep the distance locked between them? I've tried this in Photoshop, Illustrator, InDesign, Muse, Sketch but with no success. Maybe there is a plugin for that?

enter image description here

3

You can manually redistribute the spacing in a few clicks easily enough:

enter image description here

That will move objects to adjust the spacing though so that's not ideal.

Other than that your best option is probably to use some appearance attribute to create the offset and align the objects themselves with no space...

So in Illustrator with an Offset Path effect on the fill of the shapes for an example:

enter image description here

After resizing (make sure Scale Strokes & Effects is turned off):

enter image description here

You could do this with any number of attributes depending on your use case; a stroke, an offset path, inset spacing in InDesign, etc. The point is to keep the spacing as an attribute separate from the objects relative positioning.

1

Here is a script for Illustator that will do this to a user-entered width. For simplicity, I've only written it for horizontal resizing, and it only works if the items are in a group which is the first selection.

#target illustrator

var group = activeDocument.selection[0];
var toWidth = prompt ("Resize to width (pts):", Math.ceil (group.width));
if (group.typename == "GroupItem") {ResizePreserveMargins (group, toWidth);}

function ResizePreserveMargins (group, toWidth)
{ var count, i, items, item, margins=[], width=toWidth, margin, x=0;
  items = SortLeftToRight (group.pageItems);
  count = items.length;
  for (i=0; i<count-1; i++)
  { item = items[i];
    margin = items[i+1].left - item.left - item.width;
    margins.push (margin);
    width -= margin + item.width;
  }
  width -= items[count-1].width;

  for (i=0; i<count; i++)
  { item = items[i];
    if (i) {item.left = x + margins[i-1];}
    item.width += width/count;
    x = item.left + item.width;
  }
}

function SortLeftToRight (items)
{ var lefts=[], sorts=[], i, j, count, count2, item;
  count = items.length;
  // Gather & sort item left values
  for (i=0; i<count; i++) {lefts.push (items[i].left);}
  lefts.sort (function (a,b) {return a-b;});
  // Add left-to-right sorted items to final list
  for (i=0; i<count; i++)
  { item = items[i];
    count2 = lefts.length;
    for (j=0; j<count2; j++)
    { if (items[i].left == lefts[j])
      { sorts.push (item);
        lefts.splice (j,1);
        break;
      }
    }
  }
  return sorts.reverse ();
}
  • very good script! best solution until now :) Thank you! – paladinstudio Dec 13 '17 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.