0

I've searched similar questions but none matched my need. Let's say you have a lot of rectangles with different width (12mm, 35mm, 6.54mm etc) and you want to add 2mm to each object's width, 1mm both left and right. I am trying to create a quick action but Transform tool doesn't have that ability and I've tried Transform again but it doesn't seem to work when saved as an action. Would it be possible to do this by using a script? Thanks in advance! Edit: the action I'm trying to make supposed to look like this: Copy- Paste in back- Transform- Deselect. Unfortunately, the Transform part is the one I can't make to work.

0

and welcome to GDSE. Here's my solution:

The trick is to save the transformation to a graphic style first. (As actions cannot record 'effects' directly, but they register applying graphic styles).

  1. Create a rectangle and apply the desired transformation:

The red square is the original one, and the blue one has Effect/Covert to Shape/Rectangleapplied to it. In this case it already is a rectangle, so we will only be using the extra width and height. (As so often in Illustrator there are many different ways to achieve this transformation, i.e. you could also duplicate the shape and move it by certain increments)

create the transformation

  1. Next save the appearance of the blue rectangle as a new graphic style:

save a new graphic style

  1. Now you can record an action:

As you described in your question, the action copies and pastes the square in back, applies the graphic style and expands the shape.

add the action

This will create a blue shape behind the red square, that is 2mm wider on the left and right side, and 4mm taller on the top and bottom.

3
  • Thanks for replying, I've been away for a few days. Good solution to transformation, however new issue arrives and that is the appearance of rectangle. Applying graphic style means that the object now has the color defined in that style. I know I sound like I'm nitpicking, but this is important when you have different CMYK values or Pantone colors. It's good file based solution, but I'm trying to find something that will work across a multitude of different files. I really like your use of Convert to shape, as I rarely use effect in AI, and it's given me few ideas. – user153753 Jun 8 '20 at 19:39
  • Hm, adding the colour-requirements to your question makes this quite a bit more difficult, as you'll no longer be able to use graphic styles to set your transformation. Perhaps then scripting is the only viable solution. I'd be interested in what you need this for, perhaps there is another way to tackle this. – dom Jun 9 '20 at 8:38
  • Basically, this would be used as a form of trapping. I've already created several actions for different purposes(offset path, stroke etc.). I'm creating design based actions, to somewhat automate file editing. I really hope that people at Adobe expand the possibilities of Transform to more than percentage option, but until that I will try to find a workaround – user153753 Jun 10 '20 at 8:32
0

Ideally, the Transform Each function would allow this. However, it doesn't. As far as I'm aware Illustrator offers no inherent feature or tool to add a specific, measured, amount to several objects at once.

So, unless Adobe has recently added such a feature, here's a somewhat "hacky" method barring a script.

Searching for a script to do such a thing may be worthwhile. To be honest, your searching would be the same as my searching. So I really didn't bother.

This is using a collection of individual rectangles randomly drawn. Nothing is grouped or otherwise connected. I've merely selected all the rectangles.


First, add a stroke the size you wish the horizontal expansion to be for the rectangles. Align the stroke to the outside via the Stroke Panel.

enter image description here

With the stroke highlighted in the Appearance Panel, choose Effect > Distort & Transform > Transform from the menu.

  • In the Move section, enter a value which matches your stroke weight in the Vertical field.
  • For the 9-point origin box tick the top center box
    (lower left corner of the dialog window, above the Preview tick box.)
  • In the Scale section, enter any value smaller than 100% in the Vertical field.
    90% usually works well, but anything less than 95% and greater than 50% should work fine.
  • Click OK

enter image description here

Drag/drop this stroke on the Appearance Panel to the "new item" icon at the bottom of the panel to duplicate the stroke. I've changed the stroke color here so you can tell the difference.

enter image description here

Click the Transform link under this new stroke in the Appearance Panel to bring up the Effect Dialog for this stroke.

  • Enter the negative value of the stroke in the Move / vertical field.
  • Tick the bottom center box for the 9-point origin box.
  • Click OK

enter image description here

If you then change the stroke colors to match the fill color, the strokes will seamlessly extend only the width rectangles by the stroke weight.

enter image description here

You can change the stroke weight, but when doing so, you also need to open the transform effect for each stroke again and alter the Move / vertical amount to match the new stroke weight.

And, lastly, you can use Object > Expand Appearance...

enter image description here

Then click the Unite button on the Pathfinder Panel to "bake in" these strokes. Then Object > Ungroup to get things back to individual shapes.

enter image description here

You'll get extra anchors on the rectangles which aren't generally a problem. If you want to remove those extra anchors, you'll need to do that manually. Which is often faster than adding a specified width to each rectangle individually.

0

Here's an easy trick. It is only a partial solution because it

  • removes the original colors
  • makes an useless mess if the rectangles overlap, you must handle overlaps separately
  • is very likely useless for all shapes which are not rectangles with horizontal & vertical sides

A few rectangles:

enter image description here

There's no color because it would be lost anyway.

Group your rectangles for easy handling. Make 2 copies of your group with Object > Transform > Move > Copy. The copies are moved 1 mm horizontally to opposite directions:

enter image description here

Apply Pathfinder Unite:

enter image description here

Ungroup to make the rectangles free.

NOTES:

  • One copy is enough if you move 2 mm and move the result back 1 mm to keep the original center.

  • Original colors stay if you Ungroup and apply Unite separately to each stack.

  • Overlapping rectangles must be treated separately.

  • Pathfinder Unite adds a big bunch of extra nodes to the rectangles with default settings. Set Pathfinder option Remove redundant points ON if the extra nodes are considered harmful. They do not change the appearances of the rectangles, but they can be harmful if you apply Blends or 3D effects afterwards.

Path simplify doesn't remove all extra nodes (tested).

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.