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

How to select Objects outside Artboard ?

Community Beginner ,
Oct 27, 2022 Oct 27, 2022

Copy link to clipboard

Copied

Hi!

 

how can I select all Objects outside the Artboard?

ps: I don't want to delete them, so no "removeArtboardFluff" function, I want to use them...

 

THX!!

TOPICS
Scripting

Views

142

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 1 Correct answer

Advisor , Oct 28, 2022 Oct 28, 2022

I don't know why it would not work.  Try the conventional way.  (This presumes one artboard and is for items completely outside the artboard.)

app.selection = null;
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].selected = true;
    }
}

Likes

Translate

Translate
Community Expert ,
Oct 27, 2022 Oct 27, 2022

Copy link to clipboard

Copied

Select and lock all the objects that are on the artboard, then select all to grab the rest. 

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
Community Beginner ,
Oct 27, 2022 Oct 27, 2022

Copy link to clipboard

Copied

Thanks for your prompt answer!

I meant a Java-script for doing this...

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
Advisor ,
Oct 27, 2022 Oct 27, 2022

Copy link to clipboard

Copied

You could do it the conventional way, by comparing the bounds of items with the bounds of the artboard. A shorter script should be (I cannot test it at present)

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

 

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
Community Beginner ,
Oct 28, 2022 Oct 28, 2022

Copy link to clipboard

Copied

Hello femkeblanko,

using this directly in illustrator, the selection works.

But over my script, t´which is driven by an external script runner, it did not work.

The file gets opened, but nothing gets selected...

 

silverserver80_0-1666947499437.png

thx & kr

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
Advisor ,
Oct 28, 2022 Oct 28, 2022

Copy link to clipboard

Copied

I don't know why it would not work.  Try the conventional way.  (This presumes one artboard and is for items completely outside the artboard.)

app.selection = null;
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].selected = true;
    }
}

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
Community Beginner ,
Oct 31, 2022 Oct 31, 2022

Copy link to clipboard

Copied

Great! Selecting the object ouside the artboard wirks now! Thank you!!

 

Now I am losing the connection to the next step - using the selected object for pattern repeat...

Do you see, what's wrong in my script?

 

silverserver80_0-1667202190376.png

 

Here the script as text:

 

function main(inputs, outputFolder, params)
{

// Iterate through the list of inputs.
for (i=0; i<inputs.length; i++)
{
var input = inputs[i];

try
{
// Open the input file.
var myDocument = app.open(File(input), DocumentColorSpace.CMYK);

// Select all
app.selection = null;
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].selected = true;
}
}

// TILL HERE IT WORKS FINE, I HAVE AN OPENED DOCUMENT WITH A SELECTED OBJECT OUTSIDE THE ARTBOARD

// BUT HERE I AM LOSING THE CONNECTION TO THE NEXT STEP "make a row"
// THE SELECTED OBJECT SHOULD BE USED FOR IT

for(j=0; j<10; j++)
{
//make a row
for(i=0; i<125; i++)
{
newobject = object.duplicate();
newobject.translate(object.width*(i+1),-object.height*(j+1));
newobject.rotate(Math.floor(Math.random()*4)*90);
}
}

// Close the document without saving.
myDocument.close(SaveOptions.SAVECHANGES);
}
catch (e)
{
// Log problem info and set the return value to "Warning".
$.writeln("Problem while creating pattern " + input);
$.writeln("Name: " + e.name);
$.writeln("Message: " + e.message);
returnValue = "Warning";
}
}
return returnValue;
}

 

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
Advisor ,
Oct 31, 2022 Oct 31, 2022

Copy link to clipboard

Copied

I'm unsure what you are trying to do, but "object" is undefined.  If "object" is one selected item:

var object = app.selection[0];

 

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
Community Beginner ,
Oct 31, 2022 Oct 31, 2022

Copy link to clipboard

Copied

LATEST

Great, it works!
Now I just need to save the PDF in a certain folder URL and then close the document.

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