Today on Blogcritics
Home » Laziness To The Max: Automation With Macros

Laziness To The Max: Automation With Macros

As an iOS developer, I love to update my apps whenever Apple introduces a new device. Especially when that new device is an iPad with a Retina Display.

Apple’s Retina Display has four times the pixel density of a normal, 72 DPI display. It is essentially squeezing four pixels where one pixel should be by the method of doubling the vertical and horizontal pixel lengths. The new iPad has 2048 x 1536 pixels, twice the vertical and horizontal resolutions for the original iPad’s 1024 x 768 pixels.

App developers need to create higher resolution versions of their existing image resources in order to take advantage of the sharp screens. This resizing, reimporting, and retesting is not the fastest process. So how can we make it faster and more painless?

One of my apps is Geometry Stash, a geometry reference tool. Its terms and diagrams are in the Adobe Illustrator vector format. The vector format contains data for the curves and other functions in the graphic.

Illustrator reads the data and can make transformations accordingly without quality loss. Above, a curve is simply stretched.

Here’s the current process:

• Resize the Artboard through the Artboard Tool.
• Select all items and resize as Illustrator smartly sees the outermost-to-edge items as the edges for resizing.
• Export “using Artboards” to constrain the images to the right size.

This process took 18 key and mouse clicks. A waste — we’re trying to conserve energy these days!

So I looked to automating Illustrator using Actions. You can get to the Actions menu by checking Windows > Actions.

• Create a new set AKA a folder by clicking the folder button at the bottom of the window.
• Select the created set and click the new item button to the right of the folder button. This item is like a macro for Illustrator. Instead of simulating key presses, however, it will run the operations that you perform.
• Select your item and click the button with the circle on it to record operations.

Above, I recorded the operation Select All.
The next item resized both the Width and Height through Transform.
Lastly, Export to a folder.

The reason that I put these operations in separate items was that the Transform operation would not work if placed right after the Select All.

I didn’t cover resizing the Artboard? Well Illustrator Actions do not support resizing the Artboard. We can use macros to do this. A macro simulates a set of key presses. Last year, a friend of mine (yes, developers have friends) recommended that I get a mechanical keyboard. Mechanical keyboards have springs underneath each key and are more snappy. I procured a Razer BlackWidow mechanical keyboard mainly for a replacement and gaming needs.

The BlackWidow has the handy feature of being made for macros. Go figure what I did.

I recorded the following:

Shift + O Go into the Artboard tool
Enter Open up the Artboard edit window
Tab Go down to the Height field
2 0 4 8 Enter in a wdith to 2048, make sure that the keep proportions option is selected
Enter To confirm changes
V Switch to pointer tool in preparation for other Actions and macros

So now with one keypress, I could select, resize, and leave the Artboard. But wait, we can do more! Sometimes transforming the items did not resize correctly as Illustrator automatically sees outer items as the edge, as mentioned before. So we need to zoom out and then manually correct the error.No problem, there’s a macro for that!

About Anson L