Skip to main content
Participant
May 2, 2023
해결됨

How do I change the colour of a line of text generated by a .JSX script run in illustrator?

  • May 2, 2023
  • 1 답변
  • 952 조회

Hi There,

 

I am running a script in illustrtor to automate some functrions. One of the functions is to label a process based on a selection made in a drop down menu of the script. The problem is, we are rebranding and therefor changing colours and logo on the documents this script will make. 

 

Print Process Process
var Color=function(){
var c = new CMYKColor;
c.cyan=0; c.magenta=100; c.yellow=100; c.black=0; return c;
}();
templateObject.firstLevelLayers.fluff_layer.locked=false; templateObject.firstLevelLayers.fluff_layer.visible=true;
templateObject.fluff_elements.printProcess.hidden=false;
var processText=templateObject.fluff_elements.printProcess.contents;
templateObject.fluff_elements.printProcess.contents =
processText.replace(processText.substr(processText.lastIndexOf(": ")+1,)," "+userInput.printingProcess);
templateObject.fluff_elements.printProcess.name = templateObject.fluff_elements.printProcess.contents;
for(c=0; c<templateObject.fluff_elements.printProcess.contents.length; c++){
if(c>14){
templateObject.fluff_elements.printProcess.textRange.characters[c].characterAttributes.fillColor=redColor;
}

 

This line of code here is what I have found which i believe controls this text I need to change the colour of.

 

 

I have tried to change the cmyk values here, but this produces the error as follows. 

 

Any help would be appreciated!

 

Thanks

이 주제는 답변이 닫혔습니다.
최고의 답변: CarlosCanto

search for "redColor" and post the relevant portion of the code, it should be something like this

 

var redColor = .....

 

I'm assuming the code is there, but it's not being executed, so if you only post that portion we might not be able to help you. Some condition is probably not met before the redColor comes to existence

1 답변

Sergey Osokin
Inspiring
May 2, 2023

The incomplete code of the script makes it hard to imagine how the whole script works. But "redColor" is not declared in the fragment you quoted. The red color is formed in the line "var Color=function(){...}();". That is, it looks like this:

templateObject.fluff_elements.printProcess.textRange.characters[c].characterAttributes.fillColor = Color;
Participant
May 2, 2023

Thanks for your response, the entire script is around 1000 lines so i tried to narrow down where the issue might be first!

It was made for me in around 2015 by a guy who has become uncontactable. Do you have any suggestion to change the section that sayd redcolor and how to change it to match our new branding?

CarlosCanto
Community Expert
Community Expert
May 2, 2023

search for "redColor" and post the relevant portion of the code, it should be something like this

 

var redColor = .....

 

I'm assuming the code is there, but it's not being executed, so if you only post that portion we might not be able to help you. Some condition is probably not met before the redColor comes to existence