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

Referencing an object, based on it's characteristics (fill color)

Community Beginner ,
Apr 20, 2012 Apr 20, 2012

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.

TOPICS
Scripting

Views

754

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

Guru , Apr 20, 2012 Apr 20, 2012

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

    }

}

Votes

Translate

Translate
Community Expert ,
Apr 20, 2012 Apr 20, 2012

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.

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
Guru ,
Apr 20, 2012 Apr 20, 2012

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

    }

}

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
Community Beginner ,
Apr 20, 2012 Apr 20, 2012

Copy link to clipboard

Copied

Thanks a lot, that should help me get started.

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
Guru ,
Apr 20, 2012 Apr 20, 2012

Copy link to clipboard

Copied

LATEST

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.

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