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

Get PageItems applied Swatch (not color)

Guru ,
Jan 24, 2019 Jan 24, 2019

Am I correct that one can only get a pathItems fill swatch by making sure that only that pathItem is selected, color the stroke color the same as the fill color and use doc.swatches.getSelected() ?

Yuck, vomit.

The only other method that would be less reliable is to compare the color properties to the properties of the swatches. If they don't match then it's not the match and if they do then it could be or it could be another swatch with the same color properties.

Am I (I hope I am not) correct or is there a normal way of doing this?

TOPICS
Scripting
1.0K
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

Community Expert , Jan 24, 2019 Jan 24, 2019

unfortunately you're correct

the normal is there's no normal. I would probably go the other way around and loop through my swatches and select whatever has that swatch applied, do my thing, deselect, repeat. Would that approach help you?

Translate
Adobe
Community Expert ,
Jan 24, 2019 Jan 24, 2019

unfortunately you're correct

the normal is there's no normal. I would probably go the other way around and loop through my swatches and select whatever has that swatch applied, do my thing, deselect, repeat. Would that approach help you?

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
Guru ,
Jan 24, 2019 Jan 24, 2019

Thanks for the confirmation. Coming from an InDesign background I find these basic lackings in the API somewhat mindbogglingly, all I can say is that I am grateful that I basically don't take on PS jobs!

The approach you wrote could well be useful.

How can I select all items of a particular swatch with scripting?

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 Expert ,
Jan 24, 2019 Jan 24, 2019

Trevor×…  wrote

all I can say is that I am grateful that I basically don't take on PS jobs!

you mean AI jobs?

I get you, I used to be jealous of the ID/PS apis and I don't even script on those programs...but after lots of meditation hours I'm at peace with our api now.

here you go, as usual idoc is my doc reference and swatch is my swatch reference.

// assign color to default color

        idoc.defaultFillColor = swatch.color;

// find same fill color...aka select all items matching default fill color

        app.executeMenuCommand("Find Fill Color menu item");

// in case you need this too.

        idoc.defaultFillColor = new NoColor;

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
Guru ,
Jan 24, 2019 Jan 24, 2019

Thanks.

I actually did mean PS.

Although I did start on InDesign and have a much better knowledge of the ID API about 90% of my Jobs are Ai.

I do a lot of non-API stuff.

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 Expert ,
Jan 24, 2019 Jan 24, 2019

cool!!

I do 100% ai

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
Guru ,
Jan 24, 2019 Jan 24, 2019
LATEST

That's why I'm asking and you're answering

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