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

Illustrator Script not working

Community Beginner ,
Dec 15, 2020 Dec 15, 2020

Copy link to clipboard

Copied

We tried to create a script (js/jsx/vbs) to use in Adobe Illustrator, which lets us specify a RGB fill color and change it in 50+ Documents at once. We have already researched existing scripts for this purpose, but they do not work correctly.

This is our script, which is a combination of 2 existing scripts we found online:

 

var dir = Folder.selectDialog("Where are your Illustrator Documents?");var files = dir.getFiles("*.ai"); for(var f = 0; f < files.length; f++){    var doc = app.open(files[f]); 

var fillRGBColor = function (pathItems, r, g, b){

    for (var i=0; i < pathItems.length; i++) {

        pathItems[i].fillColor.red = r;

        pathItems[i].fillColor.green = g;

        pathItems[i].fillColor.blue = b;

    }

}

fillRGBColor(app.activeDocument.pathItems, 50, 50, 50);

      doc.close(SaveOptions.SAVECHANGES);}

 

 

We also found a Powerscript, which does exactly what we want, but it does not support batch processing and every file needs to be opened manually.

https://o2creative.co.nz/shop/Color_Replacer_PowerScript_for_Adobe_Illustrator

 

does anyone know how to fix this script or is there a way to make the powerscript work on multiple files ?

TOPICS
Scripting , Third party plugins , Tools

Views

1.9K

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

Community Expert , Dec 15, 2020 Dec 15, 2020

Yes. The script should work.

 

For pathItems!

 

try this part of your script with an opened document with a few PATHITEMS

var fillRGBColor = function (pathItems, r, g, b){
    for (var i=0; i < pathItems.length; i++) {
        pathItems[i].fillColor.red = r;
        pathItems[i].fillColor.green = g;
        pathItems[i].fillColor.blue = b;
    }
}

//fillRGBColor(app.activeDocument.pathItems, 50, 50, 50);  // dark grey
fillRGBColor(app.activeDocument.pathItems, 255, 255, 0);  // yellow

Votes

Translate

Translate
Adobe
Guide ,
Dec 15, 2020 Dec 15, 2020

Copy link to clipboard

Copied

Which part doesn't work?  

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 ,
Dec 15, 2020 Dec 15, 2020

Copy link to clipboard

Copied

the middle part (changing color). when i enter values for the source and new fill color, it seems to change other colours (i think mainly blacks and whites) as well... and it seems to change everything INTO the source color instead of the new one.

i dont know much about illustrator scripts so i may just be using it wrong... any help is appreciated

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 ,
Dec 15, 2020 Dec 15, 2020

Copy link to clipboard

Copied

@O2-Creative may be able to fix up a powerscript that's just right for you.

 

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 ,
Dec 15, 2020 Dec 15, 2020

Copy link to clipboard

Copied

thanks, i'll contact him/her

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 ,
Dec 15, 2020 Dec 15, 2020

Copy link to clipboard

Copied

It's him, Glenn Wilton - over in New Zealand, I think.

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 ,
Dec 15, 2020 Dec 15, 2020

Copy link to clipboard

Copied

Edit:  Your script works for me. 

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 Expert ,
Dec 15, 2020 Dec 15, 2020

Copy link to clipboard

Copied

LATEST

Yes. The script should work.

 

For pathItems!

 

try this part of your script with an opened document with a few PATHITEMS

var fillRGBColor = function (pathItems, r, g, b){
    for (var i=0; i < pathItems.length; i++) {
        pathItems[i].fillColor.red = r;
        pathItems[i].fillColor.green = g;
        pathItems[i].fillColor.blue = b;
    }
}

//fillRGBColor(app.activeDocument.pathItems, 50, 50, 50);  // dark grey
fillRGBColor(app.activeDocument.pathItems, 255, 255, 0);  // yellow

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