January 22, 2008

ASK MORDY: Distributing Objects

Today's question comes from Greg Walker:

Hey Mordy. Maybe you can shed some light onto one of my biggest Illustrator pet peeves.

Let’s say I have five boxes, and I want to distribute these boxes evenly. Seems easy enough, right? Select all the boxes and hit the “Horizontal Distribute Center” button. Often times this will work without a hitch and I can keep right on Rockin’ and Rollin’ right along. Other times, however, I’ll get the dreaded “Please choose a key object by clicking on one of the selected object(s) with the selection tool, or set the spacing value to Auto.” This drives me nuts. At the least I have to click okay and go over to the Align palette and change the spacing value to Auto and at worst I have to actually go to the trouble of opening the Align palette, which introduces even more clicks. What really gets under my skin is the apparent randomness with which Illustrator decides to change the distribution spacing from “0 in” to “Auto.” I would be quite happy for it to just stay at Auto until such time as I manually change it to some other number which will likely never ever be zero. Rarely do I draw five objects only to stack them all on top of one another.

Also, if you have the time and knowhow, is there a way to quickly center two (or more) objects both vertically and horizontally. The repeated “Horizontal Align Center” and “Vertical Align Center” click combo is a mine field of accidental clicks and subsequent undos.


Alas, the Align panel that appears in Illustrator also appears in InDesign. It is often that I lament about how difficult it is for one to decipher all the little "chicklet" icons on the panel. What makes it all the more difficult is that Adobe has combined alignment functions, object distribution functions, and spacing distribution functions all in one panel. So in addition to all of the icons, there are just so many combinations or choices at hand. As if that weren't enough, Illustrator "hides" the spacing distribution functions in the "Show Options" part of the panel, meaning that many people aren't aware that it even exists.

Hopefully my post here will relieve some of Greg's frustrations, and maybe the frustrations of others as well.

To start, I'll answer Greg's second questions first. It would be nice if Illustrator had a "Center Objects Horizontally AND Vertically" option (but that would add yet ANOTHER chicklet icon), as it's very often that designers need to center objects to each other in this way (or to the artboard if that option is chosen). Rather than click up a storm, this can easily be accomplished by recording a simple Action and assigning a keyboard shortcut to it.

1. Draw two objects on your page and select them.

2. Open the Actions panel by choosing Window > Actions.

3. Click the Create New Action button at the bottom of the Actions panel. Give the Action a name and assign a keyboard shortcut of your choice. Click Record.

4. Open the Align panel by choosing Window > Align.

5. Click the Horizontal Align Center button. Then Click the Vertical Align Center button.

6. Click the Stop Recording button at the bottom of the Actions panel.

Now you can select any objects in your document and press the keyboard shortcut you specified to instantly align the objects to each other both horizontally and vertically.

OK, so now on to the first question, which deals with the concepts of key objects and distribute spacing values and what we all affectionately refer to as "annoying dialog boxes"

The first thing one must understand about the Align panel is that it brings together three VERY different functions, yet that may not be readily apparent to the casual user. To fully grasp this, you need to make sure that the entire Align panel is expanded and visible. If it doesn't look like what you're seeing below, choose Show Options from the panel's flyout menu.



ALIGN OBJECTS:
These six options allow you to align objects TO EACH OTHER. You can use the toggle on the bottom right of the Align panel to align objects to the Artboard or active Crop Area. When objects are aligning to each other, a "key object" is defined so that Illustrator knows what you want your objects to align to. If you don't define a key object, Illustrator will appoint one for you. Anything you say can and will be used against you in a court of -- oh wait, no that's something else... For more information on defining key objects, see this post. Other alignment tips can be found in this post as well.

DISTRIBUTE OBJECTS:
These six options allow you to evenly distribute objects within a specified area. What is the specified area? Good question. In the case of alignment, you're always aligning your objects TO something else. Be it another object or an artboard, etc -- it's always a single object. But to distribute objects evenly, you need TWO key objects. By default, Illustrator picks the two objects that are the furthest apart from each other. Those objects don't move -- they remain stationery and all objects that fall between those two key objects are distributed evenly, as illustrated below.

Before:


After:


I used the Horizontal Distribute Center option in the above examples. The dashed line indicates the center of each object. After applying the distribute command, the object on the far left and right remained in place, while the two objects in between moved so that their centers were distributed evenly. The amount of space between the centers of all the objects is now consistent. However, the important thing here is that I, as a user, had absolutely NO control over the distance BETWEEN each object. The only way for me to adjust that is to move the two outer objects further away from each other (or closer together) and then reapply the distribute command. If I wanted each object to be a specific distance from each other (for example, 1 inch apart), I'd need to do the math and figure out how far the end objects need to be to make that happen.

Or, I could use Distribute Spacing.

DISTRIBUTE SPACING:

The most common mistake I see people make about Distribute Spacing is that they still focus on the objects on the page. Like any good designer knows, white space isn't just an abstract. It's SOMETHING. And to better understand what distribute spacing does, you need to think about white space. That's because distribute spacing allows you to determine the amount of consistent white space BETWEEN each object in your selection. And that's where the value comes into play. When you leave the value set to Auto, you're telling Illustrator to do the following:

1. Define the two outer-most objects as key objects. In other words, don't move those outer objects.

2. Evenly distribute the distance BETWEEN each object using the key objects as boundaries.

But if you specify a value, you're telling Illustrator to do the following:

1. Define a key object

2. Apply the specified amount of space (the Value) BETWEEN each object, starting from the key object.

Do you see the problem here? How can Illustrator perform step 1? How does Illustrator define a single key object? With the Auto setting, Illustrator could use the two outermost objects. But with a specified value, the key object can only be one object. And Illustrator doesn't know which object you want to distribute the spacing FROM. That's why Illustrator throws up the dialog, asking you to tell it which object stays still. Then it can perform step 2 as listed above. Let's take a look:

Before:


After using Horizontal Distribute Space with a value set to Auto:


After using Horizontal Distribute Space with a value set to 1p and specifying the left-most object as the key object:


And now for the kicker: Even though the design and layout of the Align panel make it seem as if the value field only applies to the Distribute Spacing functions, the value ALSO applies to the Distribute Objects functions! Surprise! This means if you have a value defined, the Distribute Objects functions don't use the two outermost objects as key objects. YOU have to define the key object. And the value that you specify is used to determine the amount of space not between the objects, but between the parts of the objects you're choosing by clicking any of the 6 distribute functions. For example:

Before:


After using Horizontal Distribute Center with a value set to Auto:


After using Horizontal Distribute Center with a value set to 4p and specifying the left-most object as the key object:


So basically, if you don't have the entire Align panel visible (i.e., the Show Options setting isn't enabled), and if there's a value anything other than Auto specified for Distribute Spacing, using any of the Distribute Objects functions will cause the "define a key object" dialog to appear.

The problem of Illustrator just arbitrarily changing the spacing value from Auto to 0 is not something I have seen. But the setting itself is indeed "sticky", meaning if you make a change, it stays until you specify otherwise. That could be what is causing the problem.

I'll admit that I use a value of "0" all the time, because when used with the Distribute Spacing option, it will automatically "kiss fit" your objects to each other. Which is incredibly useful.

As a final tip, it's important to know that the Align panel looks at groups as individual objects (those who have taken my classes or who have read my books or seen my training videos know I refer to these groups as "containers"). So if you have multiple groups selected, the alignment and distribution functions work nicely. Also, if you're using Illustrator CS3, you'll be happy to know that the align functions now properly honor the bounds of masked artwork.

NOTE: You'll notice that in all of these examples, I've used boxes of different sizes. Often, the differences between the multitudes of settings in the Align panel are indistinguishable when the objects are all the same. Mixing up different heights and widths will make things MUCH easier to understand.

Hopefully, this has cleared up some confusion. As always, I encourage readers to leave comments if more detail or discussion is required.

6 comments:

Philip Papratilov said...

Hi Mordy,
Thanks for making clear how the Align panel works. I didn't even know I could set value for the space between the objects!

I have also another question. Is there way to set the spacing between object to increase after each other object? I tried with the move tool's dialouge box by entering horizontal value of 5*2 but it calculates it and aplies it. Or even if don't remember it as 10, it remembers it like 5*2 and calculates it again the next time. Is there a way to set the value to be multiplied, but the multiplication will be calculated everytime... or is there other way to do it at all?

Philip Papratilov
(pardon my english, i'm from bulgaria, witch explains the name also)

Anonymous said...

"The problem of Illustrator just arbitrarily changing the spacing value from Auto to 0 is not something I have seen."
Oh, it definitely happens to me, too. This problem was brought up in the Adobe User-to-User forum awhile back, and James Talmage had an explanation for why it occurs. Unfortunately, I can't remember what it was...
Mike D.

darmowe gry said...

Your third point, the response and I guess re-iteration of the original
problem is that you can't import CS2 EPS files into Corel, My first
response is the EPS file format is being killed by Adobe and they're
using it as a tool to make life Miserable for any program that can't
import a PDF or their native file format. EPS is dying. Adobe is killing
it in the apps, don't expect relief soon. It's only going to get worse.
If the software you are using is relying on Adobe to export a clean EPS
that you can import, you're screwed. They are stacking the deck against
that workflow to bring users to their monopoly a the creative suite.
Indesign imports the native format of both Photoshop and Illustrator and
Adobe owns that market for illustration and imaging so don't expext them
to fix it.

Gary Spedding, Ph.D. said...

Nice job on PixelPerfect today. Glad to see you are going to give us more next week.

Gary.

Greg said...

So I set the spacing to 0, select my object, click distribute vertical spacing, and I get the dialog.

Then I click on one of the objects in order to select it as a key and...

NOTHING HAPPENS

Exactly how do you select the key object?

Anonymous said...

Hi Mordy. My co-worker and I are trying to evenly distribute 6 smaller boxes inside a wider box. We tried Distribute Space and I think I know now why Illustrator just lined the big box next to the smaller ones. We're going to align the small boxes, group and align the center with that of the wide box but that doesn't mean the space is going to be uniform. The inner spaces could be off from the space to the wall of the wide box.

What should we have done?