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.
cheers,
-J

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:

 fillColor

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

(function(){var c=new RGBColor();c.red=255;c.green=0;c.blue=30;return c;})();

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

For attributes enter:

fillColor,strokeColor


for values enter:

(function(){var c=new RGBColor(); var r = function(n){return Math.floor(Math.random()*n);} c.red=r(255);c.green=r(255);c.blue=r(255);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:

 attributes:

 stroked,strokeWidth,strokeColor


 values:

true,(function(){return Math.random()*20;})(),(function(){var c=new RGBColor(); var r = function(n){return Math.floor(Math.random()*n);} c.red=r(255);c.green=r(255);c.blue=r(255);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.