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

How to get text fill color, from the appearance panel with jsx script

New Here ,
Jun 28, 2017 Jun 28, 2017

Copy link to clipboard

Copied

I'm attempting to create an illustrator jsx script that reads text color that was applied through a graphic style.

When applying a graphic style to text, the actual color of the text does not change. Instead a fill color is added in the appearance panel.

What I would like to be able to do is read the fill color for the text frame that has been applied through the appearance panel.

From searching it seems that this is not possible directly through script... unless I'm missing something.

Pulling color through the text's characterAttributes will only pull a color that is not set through the appearance panel. Further, if a color is applied through the appearance panel, the characterAttributes color is set to nothing ([No Color]).

Are there any other techniques for getting text color that was applied through a graphic style?

The only other options I've seen is a complex setup of running an action via script, and the action will interact with the appearance panel. But this solution seems very complicated and requires each user to have the action installed, as well as the script.

Any and all thoughts are greatly appreciated

TOPICS
Scripting

Views

1.6K

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

Valorous Hero , Jun 28, 2017 Jun 28, 2017

Unfortunately this among many other things, takes more work than one would find logical.

Thankfully, we can use the app.executeMenuCommand("expandStyle"); command to break down the appearance of an art item.

Have an item selected and run this command.

In the case of text, if it has its fill as the No-Color, the text will now have its' appearance color as the character fill.

If there is a fill set on the text and there's an appearance fill, or if there are several appearance fills, it will turn into

...

Votes

Translate

Translate
Adobe
Community Expert ,
Jun 28, 2017 Jun 28, 2017

Copy link to clipboard

Copied

jonathanl79017929  schrieb

… requires each user to have the action installed, as well as the script …

… as well as the graphic style …

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
Valorous Hero ,
Jun 28, 2017 Jun 28, 2017

Copy link to clipboard

Copied

Unfortunately this among many other things, takes more work than one would find logical.

Thankfully, we can use the app.executeMenuCommand("expandStyle"); command to break down the appearance of an art item.

Have an item selected and run this command.

In the case of text, if it has its fill as the No-Color, the text will now have its' appearance color as the character fill.

If there is a fill set on the text and there's an appearance fill, or if there are several appearance fills, it will turn into a group of text items, each with the respective appearance fill now having moved into the character attributes.

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
New Here ,
Jun 30, 2017 Jun 30, 2017

Copy link to clipboard

Copied

Awesome this worked for me.

It is worth noting that if you are storing a reference to a textFrame before running the 'expandStyle' command, and you have more than 1 fillColor applied (such that the textFrame turns into a group, as described above) your reference will be broken.

This was a source of some headache for me. The solution is to ensure that the text has the colorFill set in the appearance panel and the normal text color is set to no color/transparent.

This way when calling 'expandStyle' your text should not turn into a group, but stay as a textFrame object. This is not always immediately apparent as there isn't much difference in illustrator's UI, but the steps are: Select your textFrame, set the fillColor to no color/transparent, then add a fill color through the appearance panel.

Thanks again!

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
Valorous Hero ,
Jun 30, 2017 Jun 30, 2017

Copy link to clipboard

Copied

LATEST

And for when you cannot rely on the files being strictly controlled as you say, you can duplicate the item and expand it, check the selection to see if there's a group in it. Then remove the [duplicate] item but get the returned result of your test.

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