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

Script for deleting objects on pasteboard

New Here ,
Feb 01, 2010 Feb 01, 2010

Copy link to clipboard

Copied

Anyone have a script that deletes all objects and text outside the page (or margins)?

TOPICS
Scripting

Views

4.3K

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

LEGEND , Feb 01, 2010 Feb 01, 2010

var objs = app.documents[0].pageItems.everyItem().getElements();

while(obj=objs.pop()){

if(obj.parent instanceof Spread){obj.remove()}

}

Harbs

Votes

Translate

Translate
LEGEND ,
Feb 01, 2010 Feb 01, 2010

Copy link to clipboard

Copied

var objs = app.documents[0].pageItems.everyItem().getElements();

while(obj=objs.pop()){

if(obj.parent instanceof Spread){obj.remove()}

}

Harbs

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 ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

LATEST

I love that 13 years later, I can google how to delete everything off the pasteboard, this thread is still here, and the script still works.

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
Guide ,
Feb 01, 2010 Feb 01, 2010

Copy link to clipboard

Copied

See also CleanupPasteboard.js if you need extra parameters and a dialog UI:

http://www.indiscripts.com/post/2009/09/clean-up-your-pasteboard

@+

Marc

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 ,
Jan 06, 2013 Jan 06, 2013

Copy link to clipboard

Copied

Unfortunately in my Indi CS6 any pasteboard and spread item is "instance of spread".

So i consider geometrical bounds:

myDocument = app.activeDocument

cur_Ruler = myDocument.viewPreferences.rulerOrigin;

with(myDocument.viewPreferences){

    rulerOrigin = RulerOrigin.spreadOrigin;}

myDocument.zeroPoint = [0,0];

aWidth = myDocument.documentPreferences.pageWidth*2+10;

var objs = app.documents[0].pageItems.everyItem().getElements();

while(obj=objs.pop()){

a_left = obj.geometricBounds[1];

a_right = obj.geometricBounds[3];

     if(a_right <0 || a_left > aWidth){obj.remove()}

}

with(myDocument.viewPreferences){

    rulerOrigin = cur_Ruler} //back to the RulerOrigin

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
LEGEND ,
Jan 06, 2013 Jan 06, 2013

Copy link to clipboard

Copied

This is simpler:

var objs = app.documents[0].pageItems.everyItem().getElements();

while(obj=objs.pop()){

     if(obj.parentPage == null){obj.remove()}

}

Harbs

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 ,
Jan 12, 2013 Jan 12, 2013

Copy link to clipboard

Copied

Yes! This is great. Thanks, Harbs!

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