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

Reaching Appearance with javascript

Participant ,
Sep 04, 2020 Sep 04, 2020

Copy link to clipboard

Copied

Hi,

 

My main issue right now is that I am making an automation using code only to create a design. I need to change the text appearance but can't seem to access it from the javascript.

 

here's what I got so far :

var Text = docRef.textFrames.getByName('someText').textRange;
Text.fillColor = docRef.swatches.getByName('aColor').color;
Text.strokeColor = docRef.swatches.getByName('anotherColor').color;

and it works if I don't use the appearance pannel but doesn't if I use it to modify the appearance.

Thing is that my fill color need to be over the outline. I can solve that by creating two text overlaying but I was wondering if it was something that can be done without that.

 

as always, thanks for your time and help.

 

TOPICS
Scripting

Views

290

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
Adobe
Community Expert ,
Sep 04, 2020 Sep 04, 2020

Copy link to clipboard

Copied

is this what you need? this script will add an extra Sroke and Fill to the text Frame and color those, not the characters.

 

var docRef = app.activeDocument;
docRef.selection = null;

var Text = docRef.textFrames.getByName('someText');
Text.selected = true;

app.executeMenuCommand("Adobe New Fill Shortcut");

docRef.defaultFillColor = docRef.swatches.getByName('aColor').color;

app.executeMenuCommand("Adobe New Stroke Shortcut");

docRef.defaultStrokeColor = docRef.swatches.getByName('anotherColor').color;

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
Participant ,
Sep 04, 2020 Sep 04, 2020

Copy link to clipboard

Copied

unfortunately no
The script I made already add a stroke to the text if there's none (but in my situation I just need to change its color). Thing is that I am using the appearance panel to put the stroke under the fill. But when I do that the script change an object that appear under the text for some reason.

For now I simply make a text that is the outline and one over it that is the fill. Not ideal but I guess thats what appearance does in the background anyway?

 

Image for reference only (aspect = appearance, fond = fill, contour = outline)

MikaelDufresne_0-1599241702892.png

 

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
Guide ,
Sep 04, 2020 Sep 04, 2020

Copy link to clipboard

Copied

You can also apply appearance attributes by applying a graphic style:

 

var Text = app.activeDocument.textFrames["someText"];
app.activeDocument.graphicStyles["graphicStyleName"].applyTo(Text);

 

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
Participant ,
Sep 04, 2020 Sep 04, 2020

Copy link to clipboard

Copied

But can I change the order of the outline and fill to make the fill appear over the outline?

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
Guide ,
Sep 04, 2020 Sep 04, 2020

Copy link to clipboard

Copied

I am unsure what you are trying to achieve, but you can manually create a graphic style where the fill is above the stroke, save it and apply it through a script. 

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
Participant ,
Sep 04, 2020 Sep 04, 2020

Copy link to clipboard

Copied

LATEST

The plan was to access the information I can edit manually from the appearance panel which I cannot do with the script I made. If I avoid the appearance panel I can achieve a similar effect by simply duplicating the object and using the top one for the fill and lower object for the outline.
here's a sample of what I want to achieve (middle result) with script to automate that process.
My solution is the third one but I wanted to know if there's a way to get to change colors in the appearance panel as if I use the appearance the script won't change the colors but change a version that... doesn't exist until I delete the appearance in the panel.

MikaelDufresne_0-1599245845711.png

 

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