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.
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).
- Create a rectangle and apply the desired transformation:
The red square is the original one, and the blue one has
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)
- Next save the appearance of the blue rectangle as a new graphic style:
- 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.
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.
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.
With the stroke highlighted in the Appearance Panel, choose
Effect > Distort & Transform > Transform from the menu.
- In the
Movesection, enter a value which matches your stroke weight in the
- For the
9-point originbox tick the top center box
(lower left corner of the dialog window, above the Preview tick box.)
- In the
Scalesection, enter any value smaller than 100% in the
90% usually works well, but anything less than 95% and greater than 50% should work fine.
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.
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
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.
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...
Then click the
Unite button on the Pathfinder Panel to "bake in" these strokes. Then
Object > Ungroup to get things back to individual shapes.
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.
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:
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:
Apply Pathfinder Unite:
Ungroup to make the rectangles free.
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).