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!!
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;
}
}
Copy link to clipboard
Copied
Select and lock all the objects that are on the artboard, then select all to grab the rest.
Copy link to clipboard
Copied
Thanks for your prompt answer!
I meant a Java-script for doing this...
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");
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...
thx & kr
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;
}
}
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?
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;
}
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];
Copy link to clipboard
Copied
Great, it works!
Now I just need to save the PDF in a certain folder URL and then close the document.