Posts Tagged ‘replace with symbol’

James Talmage’s Great Illustrator Scripts

Wednesday, February 25th, 2009

[Editor’s note: James has some great scripts that bring Freehand functionality into Illustrator. Ones I like are a better “replace with symbol” script than mine or John’s. Another draws legend boxes for each color used in the artwork. Two others add the ability to deselect paths that were only partially selected, or to select the unselected portions of paths is awesome. Thanks John vdH!]

Republished from James Talmage’s site.
View all of Jame’s scripts.

You’re a graphics person, right? Conventional wisdom says you’re a decidedly right-brained person. You use Illustrator to draw things, not to mess with cryptic code.

Maybe. But even if you’re the kind of Illustrator user who steers away from rulers, snaps, and numerically-entered values, and instead dives right for the Paintbrush, Symbol Sprayer, and Warp Tool, you still use Illustrator to get graphic things done and to use its features and commands. Scripting enhances both of those things.

Automation
Let’s face it: Repetition gets old, fast. It’s long been said that necessity is the mother of invention. I tend to think most cool inventions are the offspring of that cranky old couple, Laziness and Boredom. Some of the scripts in this collection arose from the shamelessly selfish desire to end the repetitious tedium of certain tasks.

But isn’t automation what Illustrator Actions are for? Well, yes. But Illustrator’s Actions Palette lets you create mere “macros.” With Actions, you can record and play back a series of most operations that you would normally perform by using the tools and commands that are directly accessible in Illustrator’s user interface. But scripts allow you to do more.

New Functionality
If little Invention was borne of daddy Laziness and mommy Boredom, he’s also been at least baby-sat by cousin Curiousity. Many of the scripts shared here were self-inflicted experiments, inspired by comments, complaints, and double-dog-dares in the Illustrator User-to-User Forums where I often hang out for recreation.

Scripting can enable you poke around a bit “under the hood” of Illustrator’s user interface, and manipulate many things from which the normal interface isolates you. For example, did you know that…

  • An Illustrator file has an internal list referred to as the “inkList” which determines the color separation plates?
  • A path can be designated closed or open, regardless of whether the whole path or just a part of it is selected?
  • You don’t have to settle for merely defining an ellipse in terms of the height and width settings of the Ellipse Tool’s dialog; you can define it like a technical illustrator often wants to: in terms of size and angle?

So it’s about more than merely automating repetitive tasks. It’s also about doing things which can’t be done with the normal feature set. Scripting effectively lets you add your own new “features” to Illustrator. All it takes is an ulterior motive, a little experimentation, and a bit of creativity. See? You don’t have to turn off the right side of your brain, after all.

Which Scripts of James’ Nathaniel Recommends:

  • Cleanup Scripts (zip | html)
  • JET_FixRegColorFromFH.jsx
    When opening a FreeHand file, Illustrator fails to assign AI’s [Registration] swatch to paths and text having FreeHand’s Registration swatch. Instead, it imports FH’s Registration swatch as a process swatch.
  • JET_RemoveSegmentsShorterThan.jsx
    Reduces the number of anchorpoints on selected paths, according to a minimum specified by the user. Removes from each selected PathItem, segments shorter than the measure entered by the user. Useful for certain types of path simplification and cleanup chores, as in imported DXF files.
  • JET_RemoveShortSegment.jsx
    General path simplification. Allows the user to specify the minimum number of segments to be retained. This script removes the shortest segment from each selected PathItem that has more than the number of segments entered by the user.
  • JET_RemoveShortSegmentsUntil.jsx
    General path simplification. Allows the user to specify the number of segments to be left for each path. This script repeatedly removes the shortest segment from each selected PathItem until the number of segments is no more than the number entered by the user.
  • Draw Scripts (zip | html)
  • JET_Centroid.jsx
    Finds the centroid (center of gravity) of selected triangles and other straight-sided multigon paths and draws a user-defined circle at that location. To use, make a selection which includes normal paths. Then call the script.

  • JET_ReplaceWithSymbol.jsx
    Replaces selected items with Instances of a Symbol from the Symbols Panel. The desired Symbol can be defined by its index number (its number of occurrance in the Panel). The document must have at least one Symbol defined. Simply select some objects. Then run the script.


  • Label Scripts (zip | html)
    JET_X_SwatchesLegend.jsx
    Creates a series of labeled squares at the bottom left of the Artboard, each filled with one Swatch in the Swatches Panel. Useful for adding a “color legend” on pages of identity graphics, to specify colors. For each named Swatch in the Swatches Palette, the script draws a square filled with the Swatch color, and creates beside it a PointType object containing the name of the Swatch. The text labels are filled with Registration color. A prompt allows the user to set the desired size of the squares (in points). The label text size is 1/3 the size of the squares.

  • Path¬†Scripts (zip | html)
    (Various scripts)
    The batch of scripts I call PathScripts are those which manipulate paths, anchorPoints and handles. Most of these are my cheezy workarounds for features which FreeHand users take for granted, but which Illustrator still lacks.
  • Selection¬†Scripts (zip | html)
    It’s no secret that Illustrator’s path/point/handle selection interface is just about the most cumbersome of all. In fact, only the most devoted Illustrator-only users deny it. These scripts are mere workarounds for some of the awkward selection chores; but they do make life a little easier in a few common situations.
  • JET_SelectSameLength2ptPaths.jsx
    Selects paths in the document which have 2 points and are the same length as the currently selected 2-point path. Purpose: to select the individual dashes of dashed lines which commonly come into AI from converted DXF files. Useful for removing “hidden lines” from such files.

  • JET_MarqueeDeselectPartials.jsx
    RWhen making marquee selections in Illustrator, all objects crossed or touched by the selection marquee are selected. Unlike most other drawing programs, Illustrator does not provide a Contact Sensitive toggle setting to cause marquee selection to select only objects which are fully enclosed by the marquee. This script deselects paths in the current selection which are only partially selected.

  • JET_MarqueeSelectRest.jsx
    When making marquee selections in Illustrator, all objects crossed or touched by the selection marquee are selected. Unlike most other drawing programs, Illustrator does not provide a Contact Sensitive toggle setting to cause marquee selection to select only objects which are fully enclosed by the marquee. This script finds paths in the current selection which are only partially selected, and adds their unselected points to the selection.
  • Transform scripts (zip | html)
    Transformation Scripts is another category for which I anticipate hacking out additional scripts. One can imagine a wide range of re-iterative transformation routines, applicable at the object/path/points/handles level beyond those already in Illustrtor’s feature set.
  • JET_StackTopToBottom.jsx
    This script re-stacks the selected objects according to their vertical positions, top to bottom. After running the script, the selected object positioned highest on the page will be rearmost; the one lowest on the page will be frontmost. This is mainly useful for correcting the stacking order of individual PointType textFrames in imported CAD drawings before concatenating them into a single AreaType textFrame, as in a parts list.