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

108

Likes

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

Advocate , 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...

Likes

Translate

Translate
Adobe Community Professional , 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");

Likes

Translate

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

 

Likes

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

LATEST

Thank You So Much @femkeblanco 

Likes

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
Adobe Community Professional ,
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");

 

Likes

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 

Likes

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