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

Script to modify fill color of outline shape in appearance panel

Explorer ,
Feb 12, 2025 Feb 12, 2025

Hi,

I have a collection of items in Illustrator which are a short text surrounded by a color circle. The circle is created via an outline shape in the appearance panel, see below.SCR-20250212-jomu.png

 

I have been trying to write a script that can change the fill color but can't seem to access that property. I retrieve the object, a TextFrame, and can access the text color via obj.textRange.fillColor, but can't seem to find how to change the fill color.

 

The documentation didn't seem to provide any methods to access the appearance properties either. I found an old message recommending the OnegaiSDK plug-in to access these, but it doesn't seem to function with CC 2025 anymore (hasn't been maintained since 2019 apparently).

 

Thanks for any ideas!

TOPICS
Scripting
431
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

Enthusiast , Feb 12, 2025 Feb 12, 2025

Set via Document.defaultFillColor.

/**
  * @File Set fill color of TextFrame
  * https://community.adobe.com/t5/illustrator-discussions/script-to-modify-fill-color-of-outline-shape-in-appearance-panel/td-p/15148110
  * @Version 1.0.0
  * @author sttk3.com
*/

(function() {
  if(app.documents.length <= 0) {return ;}
  var doc = app.documents[0] ;
  var sel = doc.selection ;
  if(sel.length <= 0) {return ;}
  
  var targetItem = sel[0] ;

  var newColor = new CMYKColor() ;
  newColor.cyan = 100 ;
...
Translate
Adobe
Advocate ,
Feb 12, 2025 Feb 12, 2025

Bonjour Alex,

il faut utiliser:

 

var doc = activeDocument;
doc.textFrames[0].selected = true;
app.executeMenuCommand ('expandStyle');

 

René

renl80416020_0-1739385239341.png

renl80416020_1-1739385345841.png

 

 

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
Explorer ,
Feb 12, 2025 Feb 12, 2025

Hi René,

I am trying to avoid using "Expand Appearance", as it is non-reversible. The text occasionally changes when I update the file, and if appearance is expanded, I then have issues with things not being centered anymore. I like the Appearance/Outline solution to generate the circles, and was hoping to find a solution to update the fill color without changing anything else.

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
Enthusiast ,
Feb 12, 2025 Feb 12, 2025

Set via Document.defaultFillColor.

/**
  * @File Set fill color of TextFrame
  * https://community.adobe.com/t5/illustrator-discussions/script-to-modify-fill-color-of-outline-shape-in-appearance-panel/td-p/15148110
  * @Version 1.0.0
  * @author sttk3.com
*/

(function() {
  if(app.documents.length <= 0) {return ;}
  var doc = app.documents[0] ;
  var sel = doc.selection ;
  if(sel.length <= 0) {return ;}
  
  var targetItem = sel[0] ;

  var newColor = new CMYKColor() ;
  newColor.cyan = 100 ;
  newColor.magenta = 0 ;
  newColor.yellow = 0 ;
  newColor.black = 0 ;

  // make only targetItem selected
  doc.selection = [] ;
  doc.selection = [targetItem] ;

  // set color
  doc.defaultFillColor = newColor ;

  // restore selection
  doc.selection = sel ;
})() ;
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
Explorer ,
Feb 13, 2025 Feb 13, 2025
LATEST

Thank you so much, that did it! You just saved me hours and hours of tedious work.

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 ,
Feb 12, 2025 Feb 12, 2025

sttk3's approach is really good.

 

Probably you already know that there are some other ways to recolour multiple objects that have Appearance panel colours in one go:

 

- Use global colour swatches and modify / replace them in the Swatches panel.

 

- Or use Recolour Artwork in the Edit menu.

 

- Or use graphic styles, modify their appearances once, and then redefine the graphic styles.

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