Skip to main content
Inspiring
June 19, 2020
Answered

AppleScript Help: How to remove all graphic lines in Document

  • June 19, 2020
  • 1 reply
  • 889 views

Hi! I could really use someone's help in writing an AppleScript to remove all graphic lines in an InDesign document that are white and 1 pt. I'm working on a document that has random white lines in it. Any help you can give me is greatly appreciated!!

 

Thanks,

Jim

This topic has been closed for replies.
Correct answer brian_p_dts

Will ExtendScript (.jsx) work?

 

var lines = app.activeDocument.graphicLines;
var numLines = lines.length - 1;
for (var i = numLines; i >= 0; i--) {
    if (lines[i].strokeColor.name == "Paper" && lines[i].strokeWeight == 1) {
        lines[i].remove();
    }
}

 

1 reply

brian_p_dts
Community Expert
brian_p_dtsCommunity ExpertCorrect answer
Community Expert
June 19, 2020

Will ExtendScript (.jsx) work?

 

var lines = app.activeDocument.graphicLines;
var numLines = lines.length - 1;
for (var i = numLines; i >= 0; i--) {
    if (lines[i].strokeColor.name == "Paper" && lines[i].strokeWeight == 1) {
        lines[i].remove();
    }
}

 

Inspiring
June 19, 2020

Thanks for replying, Brian. I'm not familiar at all with ExtendScript, so forgive me if this is a noob question! I just need to save the above as a .jsx file in a text editor and dump it in my "Scripts" folder in InDesign, correct? Then run from within the program?

 

When I do that nothing happens. The white lines remain in the document.

brian_p_dts
Community Expert
Community Expert
June 19, 2020

https://indesignsecrets.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-or-blog-post.php

 

Follow the instructions from above. You'll want to save the code as plain text with the file extension .jsx, and save it into your User Scripts folder. It will only work on the primary open document. 

 

The key is making sure you saved it as plain text. If you're using Text Edit, you'll want to use the Make Plain Test option; text edit will save as a rich text format by deault. 

 

Edit: So are you saying there's no error message, just nothing happens? What swatch color are the white lines, an actual color called White or the default Paper swatch? I used Paper in the script, but you can change the if statement to look at a different name if the name is different. And are you sure all the lines have a stroke weight of 1 pt? That's what the script is looking for. 

 

And, are they all GraphicLines, or is it the frames on Graphics that you're trying to change? Two distinct things from a scripting perspective.