Thursday, December 20, 2012

Hey All,

 I just got a message on  from user Vaughn, who was having problems getting copyToObject working in CS6.  He didn't leave an email, so I'm responding here. I've tested the script in CS6 on PC, and it seems to be working fine.  Vaughn, if you read this, please send me the problematic file so I can troubleshoot further. Otherwise, is anyone else having CS6 script issues?

Also, got a neat request from user Blair, who wanted a script to do multiple offsets like this:

 It's a great idea for an action, but sadly when you create an action, and select "Path>Offset Path..." from the Object menu, when you run the action, Illustrator stupidly keeps the source object selected, so multiple runs would create extra useless geometry.

I goofed around with the actions pallet, and discovered that when creating your action, if you use the actions fly-out to select "Insert Menu Item", and type in "Offset Path", you'll get a slightly different version of Offset Path with the expected behavior of only having the offset geometry selected, so the action can be run again immediately.

While recording your action, do this:

 When you run your new action, the "Offset" dialog cannot be suppressed  but this can be made negligible by hitting return/enter to close.  If you find that you often need to do lots of custom multi-offsets this might be a good workflow.

If you just want the same type of multiple offset for many objects, you'd be better served manually creating several offset stroke/fill combos in the appearance pallet, and saving it as a style. (which could be expanded later if you needed the geometry.)  If this sounds confusing, Google "create custom styles in illustrator". It's one of Illustrator's killer features.

 Thanks for the inspiration, and happy illustrating.


Wednesday, August 08, 2012

Update to Vary Hues

Minor update. Vary Hues will now create color variations on compound objects, and on objects in groups. Soon, I'll add some controls to give you better control.

  Sorry about not posting more, I've been busy writing a circular calendar widget for Android OS...

Sunday, April 15, 2012

Hey All!
Yes, I know... You like using my scripts, but you get a new computer with a fresh install of Illustrator, and you loathe having to download all my scripts individually. Have I got news for you...

I've finally joined the 21st century and created a GitHub repository for all my scripts. If you've never used GitHub, don't worry, all you need to know is that now you can download ALL of my public scripts in one handy zip file. Get them ALL here.

If you customize any of my scripts and think the modified version would be helpful for someone else, please feel free to fork the code.  I believe strongly in the community of JS4AI developers, and have been a little surprised at how that the playing field has been so sparse for so long.  I know there are a lot of awesome JS developers out there, so hopefully GitHub will provide a connection point to facilitate more co-development for the benefit illustrator community.  Let me know if you have any custom scripts that you want to add. Otherwise, get to downloading, and as always, happy illustrating!!!

Thursday, March 29, 2012

Matthew Ericson's MultiExport

Reader Dan just alerted me to the existence of Matthew Erickson's awesome multiExport script. His script is very similar to my exportLayers script in that it will export selected layers as various image files, but his script also manages to export layers as PDF files, and can handle multiple artboards at the same time.

The only downside is, I believe it only works for CS5 and above.  So if you're rocking CS5, check out Matt's script and his incredibly clear and thorough walk-through of how it works on Matt's blog.

I had a lot of fun looking through how he solved the dialogue/ persistent data issue. My solution was to write an entire script on the fly, and then export the script and execute it remotely.  I think Matt's closure solution is much more elegant.

Also, to save variable state between runs, his script generates an XML string, and stores it in a new textField in a hidden layer on the top of the document and then on the next run, the dialog can remember the selected values. Mad Genius. I love seeing solutions that think farther outside the box than my own efforts. 

Props to Matt for providing this open source, and for sharing his work with the world. Matt, you sir, are a Hacker with a capital 'H', and I mean that in the best possible way. 

Saturday, March 17, 2012

Draw control handles as geometry

All the anchor points and control handles below are actual geometry!

Want to be able to actually draw an objects control handles AS geometry? I have occasionally wanted this functionality while creating my script icon illustrations for 'scallop' and 'zoom and center', but I always did so by hand.

It occurred to me that this would be a good script to write,  but after doing a little Googling, I discovered that GFBroo of Jongware beat me to the punch on this one.

The discussion on the Adobe forums is here, and the direct download to the script is here.

 Very handy.... Thank's GFBroo!


Tuesday, March 13, 2012

Flow Text box to fit contents

A few days ago, Johan Ronsse requested a script that expands a text area's size to match it's containing text when some of the text is hidden by overflow.   I realized the utility of such a script, but after checking illustrator's API, I could find no native way to do it.  A few hours later, Johan sent me this link.

Nathaniel Kelso found a way to make it work.  Nathaniel's script used a really cool trick in which he grows the container, then makes a copy of the text, and flattens the text into geometry. Once the text has become a collection of graphic objects, it becomes trivial to get it's correct size. The script then deletes the geometry, and re-sizes the original text box to the correct dimensions. Brilliance!!!

Download it... Use it, and remember to send Nathaniel a thank you if you use it.
For me this was a great reminder that if you're against a wall, ask someone else.  There are always so many creative ways to solve a problem.
Stay inspired!!!

How to permanently tie a script to an action in Illustrator

 Over the years, the number one request from my followers has been the ability to permanently connect a script to an action.  
 (Note: This post is only slightly tongue in cheek)
Step 1: Go here:

Step 2: Enter this:
*****Bug Report*****
Steps to reproduce bug:

 1. Make a new Action
 2. Open Action panel fly-out
 3. Select "Insert menu Item"
 4. Insert the name of a custom script from the scripts folder.
 5. Stop recording, and test the new Action. It properly runs the script.
 6. Close, and re-open Illustrator.
 7. Run the Action... Watch it fail.

Step 3: Repeat as needed until it's fixed.

Seriously, do this at least once, and when it's finally fixed, you can claim that you played a part in making AI a better product. I'd totally put that on my resume. :)

Wednesday, March 07, 2012

The "Select Anything" Plug-in

While the script in the previous post can be easily modified for any object type, Egor just pointed out that there is a cross platform plugin called selectMenu.aip available for free from Rick Johnson/Graffix that will allow you to select many different object types. I'd perused the bevy of handy tools on Rick's site a long time ago, but had forgotten the treasures to be found there. To avoid such foolish oversight in the future, I will add Rick's site to the blogs link panel.


Tuesday, March 06, 2012

Select Compound Paths only

I got a request today to write a script that selects only compound paths. Here's the quickie script:

var doc=activeDocument;
var sel = doc.selection;

var len = sel.length;

        if(sel[len].typename ==="CompoundPathItem"){
alert("Only non-compound items are selected."); 

It should work for all versions of illustrator, and can easily be modified to other object types.



Thursday, March 01, 2012

Export Layers (up to 700% larger)

Since I posted the Export Layers script, a few people have asked me to add an option to export at a higher resolution. There is no DPI export option listed in the Adobe scripting guide, so it didn't seem likely to happen.
Yesterday, however, I received an email from Mike Moreau Jr. at HarvestMedia, who pointed out that there was an option to scale exported images.  Aaaannd, shortly thereafter, I added scaling sliders to the scripts UI.

If you need an image exported at, say, 300dpi, just calculate (desiredResolution/currentResolution) eg, 300/72 gives you 4.17.  By Setting the scale slider to 417%, your output should export at the correct size.

Note: Technically, your image is still at 72 dpi, it's just much larger, so if you want true 300dpi images, you'll need to batch process your exported images using Photoshop to adjust the size and dpi.

Also, I updated my previous post on 'organize', adding a new pic, and some notes on pro mode.

Saturday, February 25, 2012


Egor from Russia has been sending me some really good ideas for scripts lately. Last week he sent a request for a script that would 'sort by size'. I immediately slapped my forehead and wondered how I didn't think of that.

Here was his request illustration:

After goofing around a little, I thought, why settle for just positioning?
Let's make something that allows you to sort a collection of objects ALONG any attribute, BY any attribute.
 Thus organize was born. Below are a few test runs to get your juices flowing. Oh, and I added random distribution too.

Edit: Adding another example:
I've added a 'shortcuts' option, so once you get used to the options, you can enter a four digit sequence into the first prompt and the items will be sorted. I believe this interface is a good balance between hand-holding for the beginner, and speed/ efficiency for the power user.

Below I use the code to shuffle a deck of cards, and then sort their z-order depth from left to right based on their x-position. I start with a properly sorted deck:

Let me know if/how you use it in the comments, and as always, happy illustrating!

Wednesday, January 25, 2012

For the Birds

Daniel van Willigen's up to his old tricks with a new script, and it seems, a nice new place to show them off on the Behance Network.  Daniel has really taken JS4AI, and dialogues to the next level with this one.

I'll leave it as an exercise for the reader to come up with a use for it. Personally I'd just keep it around to run when I'm feeling down. Those silly birds just exude 'everything's gonna be alright...'

Also, if you're on a Mac, check out his cool new 'InfoPanel' script, which prints out assorted bits of standard printing info in a panel beneath your illustration.

Very professional looking.
Daniel assures me this will work on PC in it's next iteration.

Saturday, January 07, 2012

Set ALL the Things

Ironically, the use case for this script is very specific, but, read on...
I wanted a script that would allow me to set a bunch of  differently sized objects to an exact width.

In illustrator it is easy to scale multiple objects at once, but if they are already placed, and I just want to shrink them to an exact size... I draw a blank.

So I wrote this to fix my problem, but while I was at it, I thought it might be fun to make it a little more flexible.  You can use this script to bulk re-size things to specific dimensions. Or, if you're feeling a little more adventurous...

For more advanced (or masochistic) users:
You can also pass functions as values, for instance, assuming you entered:


as your attribute,
The following value will set color of all selected objects to red:

(function(){var c=new RGBColor();;;;return c;})();

Not super exciting, I know, but it's a start.
Another slightly more interesting example:

For attributes enter:


for values enter:

(function(){var c=new RGBColor(); var r = function(n){return Math.floor(Math.random()*n);};;;return c;})();

The above will assign a random color to both the fill and stroke of each selected object. (assuming the object had a stroke to begin with.)

Let's try an even more complex example:
To set stroke, then set random stroke thicknessess and a random stroke color, do this:




true,(function(){return Math.random()*20;})(),(function(){var c=new RGBColor(); var r = function(n){return Math.floor(Math.random()*n);};;;return c;})()

Granted, this is super messy, very error prone, and way overkill. If you want to do something this advanced, and you have the skills to write function closures in a prompt, you could easily just write your own custom script, but for quick 'one-off' tasks that don't need a script, maybe this 'advanced use' will come in handy for someone. If not, then maybe it's a good learning exercise.

Simple, or complex, let me know how you use it in the comments.  Just remember, the advanced stuff is not required, the script just defaults to 'width,height', so you don't have to do anything complicated to use it.

Update: Script now takes any standard units, so '20mm' and '6ft' are valid values.
Script now also gives you the option to transform objects from their center, rather than defaulting to top,left.