Silicon Publishing is giving away 13 scripts written by InDesign Guru Olav Martin Kvern. You can download them here. These range from utilities and examples of InDesign extensibility to graphic functions that generate art from parameters: some have been released in earlier versions, some have never been public before. Following are explanations of the scripts, along with references to further information.
It’s easy to run these scripts!
After downloading, unzip to the “Scripts Panel” folder in InDesign. On Mac this is:
Applications > Adobe InDesign 2020 > Scripts > Scripts Panel
on Win it is:
Program Files > Adobe > Adobe InDesign 2020 > Scripts > Scripts Panel
In InDesign, choose “Window > Applications > Scripts”, navigate to the “Adobe 2020 Scripts” folder, and double-click on any script to run it!
Some may require an object to be selected, as we’ll see, but if that’s the case, a message box will warn you. These scripts are safe to play around with, so let’s go through them one by one.
Adding/removing items on InDesign menus
These scripts are an introduction to making changes to InDesign menus. The first one (“Add…”) adds a “Path” submenu to the layout context menu – meaning that after you run the AddPathOperationsToLayoutMenu.jsx script, you can right-click on a selected item and use items on the “Path” submenu. Note that the “Add points” submenu item is best done after selecting the item with the Direct Select tool instead of the Pointer Tool. The “Remove…” script resets your menu back to normal.
These scripts were previously referenced in the post “Using InDesign as a CAD Tool” on InDesign Secrets.
Cool path art
This script applies fractal modifications to the path of a selected item. Here I turned the type to outlines, then ran the tool.
Draws a “mystic rose” geometric pattern, a type of construction also known as “string art”. Remember the spirograph?
NOTE: Position the zero point where you want the center of your MysticRose or NINA prior to running either script.
More Spirograph-like fun. Experiment with different parameters. You can find out more about NINAs here or see a quick tutorial (in InDesign format, of course) here.
Aside from the fun artsy effects, these scripts are illuminating in how you can work with paths using a script. Plus there’s some useful code for making dialogs using the InDesign Dialog object.
Have you ever wanted to create a new path in InDesign that follows an existing path, but is offset–inside or outside the original path–by a specified distance? Unless you’re working with a path that is symmetrical around its center point, you can’t use simple scaling to do this.
In Illustrator, you can use the path operation “Offset Path”–this creates a new version of a path that’s offset by a given distance from the original path. InDesign doesn’t have this feature. But there is an InDesign feature that we can use (abuse?) to accomplish the same task: text wrap.
When you apply a contour-type text wrap to an object, you’re creating a path around that object—and you can specify an offset distance. The text wrap path is accessible via scripting. That means that we can apply a text wrap with a given offset, then capture the path and path points of that path, turn off text wrap, and then create a new path from those geometric coordinates. OffsetPath.jsx does just that.
Saving/restoring the selection state
This script remembers the current selection for re-selecting later.
This also saves the selection, but lets you name your selection and save more than one.
This re-selects the last-remembered selection.
This is a companion to SaveSelection.jsx, letting you restore one or more saved selections.
Besides being useful, these scripts are instructive in some scripting practices such as the use of recursion, reverse iteration, and script labels. They store selection information inside the document itself, so using these will “dirty” the document (i.e., if you don’t save your document, the remembered selections won’t be available when you re-open the document later).
Extracting nested contents
Cuts the contents of a selected frame and places the resulting objects in their original position on the page. This script can remove deeply-nested objects from a frame, and is much quicker than manually selecting, cutting, and pasting the contents. The script demonstrates useful techniques such as recursion, getting the “type” of a page item, reverse iteration, and application functions such as select(), cut(), and pasteInPlace().
Sizing one thing to another
Resizes the current selection to the size of the page.
Resizes the page to the size of the current selection.
Besides being useful (for instance, you may want a page sized to an image you just placed), these scripts show how to use the resolve() and reframe() functions for getting and setting item sizes. These are better than the often-used approach of simply changing an item’s “geometricBounds” property.
Give it a whirl
Want to try them yourself? Download a zip of all these scripts here.