I’ve been working on an illustration for Wikipedia, which itself paves the way to a pictorial guide for acid-base chemistry, when I decided that it’s important to show a population of molecules in a non-photorealistic style. The illustration is shown here, as well as the process for anyone interested in replicating it – the punch-line is that this is excessively cumbersome for what it generates, and there has got to be a better way of going about it.
There are three distinct steps in this process: a pre-Illustrator step to generate the correct 3D look, a symbol creation step in Illustrator, and the final compositing, which will be discussed in the next post.
The process begins with a chemical structure. My software of choice is ChemDoodles for structure (at this writing, I think it’s superior to ChemDraw in everything, and for a fraction the price); you can use anything you want.
Save this as a .mol file. And since you’re reading this workflow, you’re probably a vector user — ChemDoodle has excellent support for vector images. You can get structures rendered in fancy styles and directly copy-paste into Illustrator; this worked even back at a certain time when OSX’s native vector export was FUBAR’ed.
We’ll bring this file into Avogadro, an open source molecule viewer. It natively does molecular mechanics structure optimization, and that would work just fine for our simple aniline. The other options prepare input decks for plugging into commercial (e.g., Gaussian) and open-source (e.g., NWChem) quantum mechanics software.
At this point we have a structure on our screen which is of correct geometry. Select a good angle and export as “vector graphics PDF” (which despite its name, is not a true editable vector in Illustrator!) Repeat for two different view-points; later on we will use rotate and scale these three views to simulate a chaotic mix of molecules. I chose the following views.
Illustrator Symbol Creation
To quickly recap, at this point we have 3 different PDFs for the aniline molecule. (To keep them organized, I named them “aniline-side”, “aniline-in”, and “aniline-out” after the position of the functional groups relative to the ring.) Each of these PDFs contain a black background as well as a separate molecule object (as non-editable construct). Delete the back black object to get to the molecule (and an axis by default):
Note that if your color space is not setup correctly, there will be difference in what is observed in Avogadro and what is seen in Illustrator. To remove the axis, draw a rectangle over the molecule, select both objects, and use the top as a clipping mask:
I thought it was too dark for what I need, so I reduced the opacity to 75%. This is entirely optional aesthetics.
Now we come to the ambient music listening time (i.e., mind-numbing bit). To simulate the drawn appearance, we’ll lock (cmd-2) and trace over the figure with the Pen tool (shortcut P). (I hope you like pulling Bezier curves.) My recommendation here is to draw closed shapes for each atom, as that allow you the flexibility to control the fills with nice gradients or gradient meshes. The way I go about generating this is by first drawing overlapping shapes (see left figure), then use the Shapebuilder tool (short-cut shift-M) to trim the edges. You could use the pathfinder to do these boolean operations if you prefer – but I find the shapebuilder much more speedy for this task.
To generate a true vector, fill these closed shapes with appropriate gradients, using colors sampled from the original. Adjust the line style and stroke weight to your liking. Note that you could skip this step and create a hybrid illustration by simply unlocking the original. In any case, group all the elements together, and you almost have a new symbol!
One note before you’re done: unlike normal objects which are knockout by default, Adobe’s transparency model place transparent objects as overprints. If you want to avoid partially transparent shapes from overlapping with one another what you could do is to apply a new opaque white fill to the back of the group (see figure for settings). This takes care of the the overlapping transparent pieces. (I think there must be a more technically sound way of handling this using blend modes and knockout group options in the transparency panel, but I don’t know.)
When you’re happy with how your molecule looks, drag it into the symbol tray, and give it a name so you can tell what it is later:
This creates a symbol, which can be introduced in large numbers using the symbol spray tool .
Repeat for other views and molecules as necessary. The advantage of using symbols, as opposed to straight up manipulation, lies not only in the tools available in Illustrator for spraying and manipulating them, but also in the flexibility of being able to edit any one of the instances and have it propogated to all other instances automatically.
My completed collection of molecules, in charged and uncharged forms, looks like this:
The “charges” are simple circles with a radial gradient and the appropriate parts cut out. The next part is fun – it leverages all the grunt work to generate pretty pictures.
With the symbols now created, you can simulate a population of molecules easily using the Symbol Spray tool, then use the Sizer and Spinner to create variations within the sprayed molecules. For organization’s sake, I created three separate layers:
(a) far away layer: scaled down molecules, low opacity (40%).
(b) mid layer: mid-sized molecules, ~75% opacity.
(c) close layer: big molecules, fully opaque.
(If you have tools like Phantasm CS, it might be worthwhile to slightly darken and desaturate the back layers to simulate atmospheric perspective.)
The details of the lower left panel:
I was surprised at how quickly resolving these shapes drag down the computer: while theoretically there are no upper bound to the number of molecules thus sprayed on, my machine was stuttering with more molecules. This is one reason why I thought there has to be a better way of going about it – there’s simply too much grunt work involved for what it is.
The real kicker came after I uploaded it to WikiCommons. Wikipedia takes SVGs and not PDF/AI files; between a deficient renderer and limited expressiveness of SVG, the files thus generated was displayed incoherently. (The troubles with transparency reminds me of Illustrator 9’s troubles back 10-12 years ago with PostScript and printing.) At the end I had to rasterize the individual pieces of graphics before packaging it up into a SVG (so that the text remains easily translatable). While vector shapes are gorgeous (and rational), it’s sadly the wrong tool for this particular task. The better solution will be described in the sister post, How to Draw a Population of Molecules (3D Modeling Route).