Wednesday, December 14, 2011

Unscaling pasted images

In the past few releases of the CS suite, I've found that when I paste an image from the windows clipboard into Illustrator, the pasted image size is reduced to about 70%.  I hope there is just some setting that can turn this off, but being the lazy programmer that I am, I just wrote a couple lines of code to knock the imported graphic back to 100%.

This script can be run on multiple selected items at a time, and will only affect Raster Items.
If the selected item is already at 100% it will not be transformed.


Wednesday, November 23, 2011

Generate Color Legend from Swatches

Here's a simple script that will generate color rectangles in a document for every color in the main swatch palette.

Suppose that you want to create a visual legend of some colors.  This script will make a map of ALL the swatches in the documents swatch palette.  (If you want to skip the "none" and "registration" values, just edit the script so the "for" loop start at 2 instead of 0.)

Just run this script, and a legend of named swatch rectangles with (by default) their CMYK values will appear in a nicely grouped object on the top of your document.

Sound off in the comments if you find this one useful.


Thursday, November 10, 2011

Script Bay: Run Any Script from a Panel

One of my users just sent me a message about a new (free) Illustrator plug-in that allows you to run any script on your hard drive from a unified panel.

The website says that it is only compatible with CS4 and above, but this sounds like a huge convenience for those with compatible versions. Check it out!

Saturday, October 29, 2011

Expand a raster tracing object

This week Hugo Tait sent me an excellent question about how to expand a tracing object.

Unfortunately, there wasn't much of an example in the javascript guide.
It took a little experimentation, but I came up with the following script, and thought I'd share it with all of you here. This will take the current selected Raster object (embedded not placed) and convert it into 4 color geometry.

var doc = activeDocument;
var obj = doc.selection[0];
var r = obj.trace();
var options = r.tracing.tracingOptions;
options.tracingMode = TracingModeType.TRACINGMODECOLOR;


Thursday, July 21, 2011

Update to Scallop Template

I was thinking about Hiroyuki's 'connect the dots' script, and was wondering, what happens if you have a reverse need, where you have a spline, and you want to distribute an object across all the anchor points.

I remembered I had written something like that when I made the Scallop Template script, but I dialed it down to only sharp corners, because it seemed silly to put a scallop in the middle of a rounded segment. I have now updated scallopTemplate.js with the option to draw a circle around sharp corners only, or around all anchor points.

If you have a line graph, you can use scallopTemplate to drop circles over the anchors like this:

If you then ungroup the circle objects, you can  then use copyToMultipleObjects to replace the circles with whatever object suits your fancy...

If for some reason, you don't like the extra click, and plan to only use one or the other, you can edit line 26 of the script from:

var selectAll = confirm("Scallop corners only?");


var selectAll = true;
Have fun!

Showcase: Scott Daris

Hey All,

I got a wonderful email from Scott Daris, a graphic designer who is using my scripts for a variety of designs ranging from editorial illustration to non-profit work. Upon request, Scott was kind enough to send me some examples of his work.

I like seeing what people do with my scripts, and hopefully you do too, because I'm posting them here.

Scott used vary_hues.js to quickly turn this collection of grey blocks:

...into this one:

In his words:
I used it for quickly colorizing the squares in the buildings for a little editorial illustration. I know you can achieve this effect in other ways, such as object mosaic, Recolor Artwork, etc, but your script was great because I quickly did a bunch of them, automatically randomizing the colors so each one was different, and then just picked my favorite one. Easy!

Scott is also a fan of textTweaker.js, which he used as a starting point to add a playful feel to the typography below, creating cool blocks of text that ooze with personality.

I hope these use cases inspire you, as they inspire me, to create something new.


Monday, June 13, 2011

Connect the Dots II

Hiroyuki posted an update to the connect the dots script, which sets a maximum difference between connectors. 

This allows for some REALLY COOL stuff.

I found a copy of a voronoi stipple program similar to the one mentioned, which makes VECTOR pointallized svgs using the command line. (these CAN absolutely be loaded by Illustrator) 

The advanced options didn't seem to work for me on initial try, but after opening a 'cmd' window and navigating to the containing folder, the following ran fine, although it took about 3 minutes to finish.

voronoi.exe test.png out.svg

I also ran across a really neat way to take things a step further using a Traveling Salesman Solver python script for Inkscape at the EvilMadScience site. I didn't try this one because I don't have inkscape installed, but after seeing that you can write scripts for it in python, I might just take it for a whirl...

Anyway, cool art abounds. I am in awe. 

Thursday, June 02, 2011

Distribute Stacked Objects to a grid (sort of...)

Hey All,

New script goodness!!!

Distribute Stacked Objects is a script I cooked up to take any number of selected objects, and spread them out a bit.  The script doesn't create an exact grid, but it does prevent objects from overlapping, which is handy if you've just imported 50 .eps icons. Take it for a spin and see if it improves your quality of life. I've tested it on CS5 for Windows.  Good luck, and happy illustrating.

right click here to acquire.


Saturday, May 28, 2011

Connecting the Dots

Hiroyuki just posted a new script that connects the dots, literally. It draws a line through the centers of a collection of selected objects with options such as nearest horizontal, nearest vertical, nearest, farthest, etc...

I haven't played with it yet, but it looks like it could be a really fun toy, and possibly even a handy visualization tool.  I'm going to run it on a few of my latest logo projects and see if I can get it to do something unexpected.  Post in the comments if you find an interesting way to use this script. Mad props to Hiroyuki, dude, keep on script'n!

Saturday, April 16, 2011

Save Layer States

OK, here's a really quick shot at saving layer states.

The script doesn't track by layer name, so if you add or remove a layer between uses, your layer visibility will be shifted. Fortunately, I'm using a simple system of 1's and 0's to track visibility, so you can easily edit the saved values if you added or removed a layer between runs.

Another limitation/caveat: This version doesn't look at sub-layers, just top level layers.

Someone who know how to write plugins should probably write something like this, but until then, if you're dying for a layer "save state" script, this should get you started.

Just run the script posted below and a prompt will come up with a bunch of ones and zeros in the text entry field. These represent the visibility of each root layer in your document. If you want to save your layer state, just manually copy the prompt data to a text document for use later.

When you want to reset your visibility to an older saved state, just rerun the script, and paste your saved string back into the prompt window, (erasing the existing data) and your layers will return to the original visibility settings.

Enjoy, and if you have any suggestions, requests or improvements, please email me, or post in the comments below.

var doc = activeDocument;

var binArr=[];
var i = 0;

for(var d=doc.layers.length-1;d>=0;d--)
        i= doc.layers[d].visible ? 1:0;

var p=prompt("Copy values to store layer visibility states, paste new data below to change.",binArr.join(""));

if (p!=null)
    binArr = p.split("");
    for(var d=binArr.length-1;d>=0;d--)
            if(doc.layers.length  > d){
                doc.layers[d].visible  = binArr[d] ==    0   ?  false : true;

Thursday, April 07, 2011

Quick and Dirty Label Layers

Here's a simple script I wrote to auto-label layers. It will only label the layers of objects that you've selected, and it will only label a layer if the object has a name, or is a placed image with a image link.
If an object has a name, that will take priority over the link name.  I might make this an official script, but meanwhile, take this for a testdrive. Just copy the script below and save it as
It should work cross platform.  Let me know how it goes...


// AutoLabelLayers.jsx beta JS4AI script by
var doc = activeDocument;
var sel = doc.selection;
var selLen = sel.length;

//prevent renaming of existing layer names.
var renameLayers = true;

for(var x=0; x<selLen;x++)
function assignLayerName(obj)
    var imageName = getName(obj);
    if(imageName != null)
        var layer = obj.layer;
        while (layer.parent.typename=="Layer")
            //name all layers up the layer tree:
           // = imageName;
            layer = layer.parent;

function nameLayer(_layer,_name)
        if(   ("Layer ")  == 0)  ||   (renameLayers == true)  )
   = _name;

function getName(obj)
       if (>0)
   if(obj.typename == "PlacedItem" || obj.typename == "RasterItem" )
        var nString = obj.file.toString();        
        var fileDiv="\\";
        if(nString.indexOf("/")  != -1)
            fileDiv = "/";
        var nArr = nString.split(fileDiv);
        var nString = nArr[nArr.length - 1];
        if(nString.indexOf(".") == nString.length-4)
            nString = nString.split(".")[0];
        return nString;        
return null;