• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

AppleScript Help: How to remove all graphic lines in Document

Explorer ,
Jun 19, 2020 Jun 19, 2020

Copy link to clipboard

Copied

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

TOPICS
Scripting

Views

444

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 19, 2020 Jun 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();
    }
}

 

Votes

Translate

Translate
Community Expert ,
Jun 19, 2020 Jun 19, 2020

Copy link to clipboard

Copied

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();
    }
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 19, 2020 Jun 19, 2020

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 19, 2020 Jun 19, 2020

Copy link to clipboard

Copied

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

 

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. 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 19, 2020 Jun 19, 2020

Copy link to clipboard

Copied

LATEST

Thanks, Brian. The script does work! I opened a new doc in InDesign and put in one rule at 1 pt and colored it white. POOF - Deleted. Now I just need to figure out why it doesn't work in my original document. Thanks, again!!

 

UPDATE: You called it, Brian! I thought that the color was "Paper", but it was "White" in the swatch panel. I changed that in the script and it works great! Thanks for your patience and help! Much appreciated!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines