Copy link to clipboard
Copied
Hello scripters
(This might be very basic, if so I still haven't managed to find it anyware.)
Is there some way to reference an object based on it's characteristics, for instance it's fill color, and then manipulate it (delete it, move it)?
I would be greatful for any help.
Here is an example:
Main();
function Main() {
var doc = app.activeDocument;
var rectangles = doc.rectangles;
var swatch = doc.swatches.item("C=15 M=100 Y=100 K=0");
for (var i = rectangles.length-1; i >= 0; i--) {
if (rectangles.fillColor == swatch) rectangles.remove();
}
}
Copy link to clipboard
Copied
No. To find an object based on its characteristics, you have to manually loop over each possible candidate and check one by one.
Copy link to clipboard
Copied
Here is an example:
Main();
function Main() {
var doc = app.activeDocument;
var rectangles = doc.rectangles;
var swatch = doc.swatches.item("C=15 M=100 Y=100 K=0");
for (var i = rectangles.length-1; i >= 0; i--) {
if (rectangles.fillColor == swatch) rectangles.remove();
}
}
Copy link to clipboard
Copied
Thanks a lot, that should help me get started.
Copy link to clipboard
Copied
By the way, in Apple Script you can reference an object based on it's characteristics like so:
tell application "Adobe InDesign CS5.5"
set doc to active document
tell doc
set red_swatch to swatch "C=15 M=100 Y=100 K=0"
tell (rectangles whose fill color is red_swatch) to delete
end tell
end tell
This is the same script as above.