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

How to select Objects outside Artboard ?

Community Beginner ,
Oct 27, 2022 Oct 27, 2022

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
1.9K
Translate
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

Guide , 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;
    }
}
Translate
Adobe
LEGEND ,
Oct 27, 2022 Oct 27, 2022

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

Translate
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

Thanks for your prompt answer!

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

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

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");

 

Translate
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

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

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

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

 

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

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

var object = app.selection[0];

 

Translate
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
LATEST

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

Translate
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