A friend sent me an email today with a question about a logo they were working on. It was an object that was filled with a gradient mesh, and they were trying to punch out a hole from the middle of it. Only it seems that Illustrator wasn't letting him create a compound path because you can't create one with a gradient mesh object.
I thought it would be good to talk about this here, because there are two interesting points to take away from the solution that I gave him. In fact, the solution itself was pretty easy -- create a mask. By creating a compound path (or compound shape) of the final logo, you can simply overlay that shape over the gradient mesh, and use it as a mask. That way you only see the gradient mesh through the mask (imagine if the gradient mesh were a placed image). Perfect, right?
The "problem" though, is creating the shape that will be the mask. You would think that you can just make a copy of your gradient mesh object and use it to create the compound path, but you can't because it isn't a path -- it's a MESH.
A mesh is a special kind of object. If you draw a path and look at the Appearance palette, you'll see that the palette tells you that you have a Path targeted. However, if you draw a path, click in that path with the Mesh tool, and then look at the Appearance palette, you'll notice the target is now a "Mesh Object". A mesh object is not a normal path in Illustrator. It's a special KIND of path called a mesh object. And there are certain things that you can't do with mesh objects -- notably, you can't use them in compound path or compound shape operations. There are other limitations as well.
So the problem is, once you turn a path into a mesh object, you can't turn it back into a path (once a mesh, always a mesh!). So if the logo is a mesh, how do I then get a path that matches my shape that I can then use for a mask?
The answer, my friends, is to create a new path from the mesh object. And you can do so by selecting the mesh object and choosing Object > Path > Offset Path. For the Offset value, enter 0. Zilch. Nada. Nothing. This will create a new PATH that is identical to the mesh object. You can then use the newly-created path to create a compound shape that can then be used as a mask for your mesh object.
This technique also appeals to Flash designers. When you create a gradient mesh in Illustrator, that artwork can't translate as vector into Flash, and so the result is going to be a big fat juicy raster image when you import it into Flash. Many designers may choose instead to bring a solid-filled object into Flash and apply a gradient to that shape in Flash, which would keep it vector and reduce the file size (of course, the appearance would change). However, how can you get that mesh into a path that Flash will understand? Same technique -- use Offset Path to create a new path with the same dimensions as the mesh object.