Adobe Illustrator has had a Stray Anchor Points remover for some time. In Illustrator CS3, you can remove stray points by selecting Object > Path > Clean up… The Clean Up command allows for deletion of Stray Points, Empty Text Paths and Unpainted Objects. InDesign on the other hand doesn’t contain such a command.
How do we create strays?
What generates Stray Points? Well, you can simply click with the Pen Tool found in InDesign, Illustrator, Photoshop anywhere in your document, then choose another tool and… you’re left with a Stray point. A more common way for people to end up with Stray points in their documents – and that doesn’t necessarily need to be an Illustrator document – is through deletion of line segments, using the Direct Selection tool (Illustrator, InDesign, Photoshop).
Why does this happen? A line, straight or not, can not exist without two points, in fact the line segment is a connector between two anchor points.
Line segment – Closed path or closed path with 3 or more segments
Q: So what happens when we grab the Direct Selection tool and select a line segment on a closed path? Or when we select a line segment in the middle of an open path that contains at least 3 or more segments and press Delete?
A: The line segment is removed and the two points that were previously joined by this line segment stay behind and are joined to the remainder of the line segments with which they shared anchor points.
In other words all works as expected: A closed path turns into an open path, and single open path turns into two separate paths.
Line segment – End of path with 2 or more segments
Q: But what happens if the line segment we delete is the segment located at the either end of an open path?
A: In this case we’re left with one stray anchor point, simply because this happens to be a point that isn’t shared with a joining line-segment.
Q: So how can we prevent getting stray points?
A: There is an easier method to prevent the stray point from appearing when you want to remove a line segment positioned at the end of a path.
A: Instead of deleting the line segment itself, which leaves the orphaned point behind, select the end point of the path, then press delete. As the line segment can only exist as a connector between two points, the removal of its end point results in automatic removal of the line as well. And… NO strays!
Single line segment
Q: So what about deleting a single line segment I hear you say? Am I not going to be left with at least one stray point, even if I select an anchor point?
A: Well, that is true, but why use the Direct Selection tool at all? Unless you have a reason for wanting to retain at least one or two stray anchor points, just use the Selection tool to select and delete this line and its points.
Stray point deletion script for InDesign
Well, after all of this you’ll probably inherit artwork that still has stray points distributed throughout the document. In Illustrator, the Clean Up command will help out, but InDesign doesn’t have a Delete Stray Point or Clean Up command. Dave Saunders has come to the rescue!
A very recent post — the reason I thought I’d write this one up — at the Adobe User 2 user forums, prompted Dave Saunders, InDesign script-writer extrordinair, to write two scripts for InDesign. One which locates stray points within a selection or entire document, the other simply removes stray points found.
Copy the text from this post into a new ExtendScript Toolkit file and save the file as “Delete Stray Points.jsx” into your InDesign Scripts Panel folder inside the Scripts folder located in the InDesign application folder on your system. You can even assign a Keyboard shortcut to the script if you think you’ll be using this script a lot.