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

Script to delete text and path items present outside the Artboard

Explorer ,
Apr 22, 2022 Apr 22, 2022

Copy link to clipboard

Copied

Hello All,

 

I just want ask, whethere any possibilites are there in scripting to delete the text and path items present outside the artboard.

 

For Example:

Surya24_0-1650652378787.png

I want to delete the rectangles and text present outside artboard for 100's of files. As of now, I am doing manually. 

 

Please let me know any possible and quick way using scripting.

TOPICS
Scripting

Views

1.0K

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 2 Correct answers

Guide , Apr 22, 2022 Apr 22, 2022

This should delete anything partly or completely outside the one artboard:

 

var doc = app.activeDocument;
var items = doc.pageItems;
for (var i = items.length - 1; i > -1; i--) {
    var b1 = items[i].geometricBounds;
    var b2 = doc.artboards[0].artboardRect;
    if ((b1[0] < b2[0] || b1[2] > b2[2]) || 
        (b1[1] > b2[1] || b1[3] < b2[3])) {
        items[i].remove();
    }
}

 

This should delete anything completely outside the one artboard:

 

var doc = app.activeDocument;
var items = doc.page
...

Votes

Translate

Translate
Community Expert , Apr 22, 2022 Apr 22, 2022

here's a very crude alternative for educational purposes

 

app.executeMenuCommand ("selectallinartboard");
app.executeMenuCommand ("Inverse menu item");
app.executeMenuCommand ("clear");

 

Votes

Translate

Translate
Adobe
Guide ,
Apr 22, 2022 Apr 22, 2022

Copy link to clipboard

Copied

This should delete anything partly or completely outside the one artboard:

 

var doc = app.activeDocument;
var items = doc.pageItems;
for (var i = items.length - 1; i > -1; i--) {
    var b1 = items[i].geometricBounds;
    var b2 = doc.artboards[0].artboardRect;
    if ((b1[0] < b2[0] || b1[2] > b2[2]) || 
        (b1[1] > b2[1] || b1[3] < b2[3])) {
        items[i].remove();
    }
}

 

This should delete anything completely outside the one artboard:

 

var doc = app.activeDocument;
var items = doc.pageItems;
for (var i = items.length - 1; i > -1; i--) {
    var b1 = items[i].geometricBounds;
    var b2 = doc.artboards[0].artboardRect;
    if ((b1[2] < b2[0] || b1[0] > b2[2]) || 
        (b1[3] > b2[1] || b1[1] < b2[3])) {
        items[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 ,
Apr 23, 2022 Apr 23, 2022

Copy link to clipboard

Copied

Thank You So Much @femkeblanco 

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 ,
Apr 22, 2022 Apr 22, 2022

Copy link to clipboard

Copied

here's a very crude alternative for educational purposes

 

app.executeMenuCommand ("selectallinartboard");
app.executeMenuCommand ("Inverse menu item");
app.executeMenuCommand ("clear");

 

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 ,
Apr 23, 2022 Apr 23, 2022

Copy link to clipboard

Copied

Thank You So Much @CarlosCanto 

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
New Here ,
Aug 23, 2023 Aug 23, 2023

Copy link to clipboard

Copied

LATEST

this works only for one page, but when i have a multi-artboard it deletes all except the active artboard.
Could you please re-script to make it delete all out artboard without deleting inside multi-artboard

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