Easy Right‑Angled Line Script – Automate Leader Lines in InDesign

Tired of nudging anchor points just to square‑off a call‑out?
Whether you’re labelling a product diagram or building an infographic, keeping those little leader lines perfectly horizontal and vertical is a repetitive pain. And if the line has to dodge an image—forming a tidy “C” or “S” shape—the manual tweaking multiplies.

The Easy Right‑Angled Line Script wipes out that busy‑work:

  1. Draw a plain, straight Graphic Line from source to target.
  2. Keep it selected and run Create_Right_Angled_Line.jsx.
  3. Mess with the settings until it looks right, and hit OK.
  4. Bam – the script redraws a surgically straight “L”, “C” or “S”‑shaped leader.
  5. Not quite right? Just select the line again and re-run the script.
  6. Need to flip the bend? Just tick “Swap line directions”. No redrawing, no lost anchors.

Why you’ll love it

Time‑SaverHow the script helps
Perfect right anglesGenerates orthogonal bends automatically – no eyeballing.
Keeps original anchorsStart & end points stay locked to your artwork; only the mid‑points move.
Instant “C” / “S” shapesA single checkbox adds a third segment; the distance is set with a synced slider + textbox.
Live, modeless previewTug the slider and watch the path update in real time without blocking your document.
One‑click undoEach preview refresh and the final commit are grouped into tidy History entries.

Script (GitHub Gist)

Here’s the goodies:

Quick install

  1. Download the script (link to GitHub Gist – see options below).
  2. Drop SquareLineSelector.jsx into your InDesign Scripts > Scripts Panel folder.
    • For me, on Windows, it’s located here: C:\Program Files\Adobe\Adobe InDesign 2024\Scripts\Scripts Panel
  3. Restart InDesign or refresh the Scripts panel.
  4. That’s it – double‑click the script whenever you need a square leader.
  5. You can also open your scripts panel -> right click on a folder -> click on Reveal in Explorer and that will open your scripts location too.

Target version: Written and tested in InDesign 2024/2025 (ExtendScript).
The #targetengine "SquareLineSelector" directive keeps the palette open between runs.

UI tour

<!– optional visual –>

ControlFunction
Swap line directionsChoose whether the path goes horizontal‑then‑vertical or vertical‑then‑horizontal.
3‑sided lineAdds an extra leg so the path can dodge content (“C” or “S”).
3‑sided distance (slider + textbox)Live‑linked widgets. Drag for rough length, type for precision (supports –1000 → +1000 px).
Live previewToggle real‑time updates. Disable if you’re manipulating huge files.
OK / CancelCommit or revert in a single undoable step.

(The previous “Selector on opposite end” option was removed in v1.1 – it’ll return when custom end‑caps land.)

Under the hood – what changed in v1.1?

Areav1.0v1.1 (current)
3‑sided orientationDropdown to pick horizontal/vertical extra legOrientation is decided automatically by the current bend direction – one less click.
Distance sliderFixed 0–300 pxDynamic – range shifts ±1000 px around your current value so you’re never constrained.
Placeholder optionsEnd‑selector & styling checkboxesCommented‑out code removed for clarity; ready for future bolt‑ons.

Geometry engine highlights

jsxCopyEdit// Mid‑anchor(s) calculation
if (swapDirection){      // vertical‑then‑horizontal
    midAnchor = [xA, yB];
    if (threeSided) {
        midAnchor     = [xA, yA + dist];
        midAnchorTwo  = [xB, yA + dist];
    }
} else {                 // horizontal‑then‑vertical
    midAnchor = [xB, yA];
    if (threeSided) {
        midAnchor     = [xA + dist, yA];
        midAnchorTwo  = [xA + dist, yB];
    }
}
  • No math libraries required.
  • Resulting pathArray rewires the line in one hit, then sets fillColor = "None" to guarantee a hollow stroke.

Real‑world tips

  • Pre‑define an Object Style for leader strokes. Convert first, then apply the style to lock in weight & colour.
  • Use Live preview sparingly on mega‑sized documents – disable it if you notice lag, set your parameters, then click OK.
  • Batch it with Actions: run the script on each leader, hit the same OK settings, and you’ll be done before you could drag a second anchor by hand.

Extending the script

The heavy lifting lives in updateSquareLine(), so you can safely splice in extras:

  • Arrow heads – InDesign supports strokeStart / strokeEnd.
  • Custom selector caps – draw a tiny shape after the path is rebuilt.
  • Dynamic stroke styles – query the slider value and switch to a dashed line beyond X px.

Feel free to fork the Gist and send a pull request – we love seeing improvements!

Limitations & gotchas

  • Works on one selected Graphic Line at a time (to avoid ambiguity).
  • Ignores Bézier curves – your source line must be straight.

Leave a Reply

Your email address will not be published. Required fields are marked *