So I'm very, very new to PS scripting and I'm not sure where to begin. I have data driven graphics fed from a csv file. What I need to do is:
If the text value of Layer(Answer1 OR Answer2 OR Answer3 OR Answer4) = the text value of a hidden Layer(CorrectAnswer) Then
Change the color of the text for Layer(Answer1 OR Answer2 OR Answer3 OR Answer4) to #A62124
End If
I'm guessing this would be run as a script during processing, but I'm not sure how to do it, or what he code should be. Can anyone help me out?
Data Driven Graphics Question
-
Mike Hale
Data Driven Graphics Question
If you want to control the text color as part of the basic data driven graphics part of the workflow you can do that with layer visibility and the csv file. That would give you the advantage of doing everything in one pass.
Just changing the color of the text based on it's contents matching another text layer isn't really data driven graphics. It should be easy to do but I think you will need more than one if statement. Here is one way this can be done image by image.
Code: Select allvar correctAnswerColor = new SolidColor();
correctAnswerColor.rgb.hexValue = 'A62124';
var correctAnswerText = app.activeDocument.layers.getByName('CorrectAnswer').textItem.contents;
if(app.activeDocument.layers.getByName('Answer1').textItem.contents == correctAnswerText) app.activeDocument.layers.getByName('Answer1').textItem.color = correctAnswerColor;
if(app.activeDocument.layers.getByName('Answer2').textItem.contents == correctAnswerText) app.activeDocument.layers.getByName('Answer2').textItem.color = correctAnswerColor;
if(app.activeDocument.layers.getByName('Answer3').textItem.contents == correctAnswerText) app.activeDocument.layers.getByName('Answer3').textItem.color = correctAnswerColor;
if(app.activeDocument.layers.getByName('Answer4').textItem.contents == correctAnswerText) app.activeDocument.layers.getByName('Answer4').textItem.color = correctAnswerColor;
Just changing the color of the text based on it's contents matching another text layer isn't really data driven graphics. It should be easy to do but I think you will need more than one if statement. Here is one way this can be done image by image.
Code: Select allvar correctAnswerColor = new SolidColor();
correctAnswerColor.rgb.hexValue = 'A62124';
var correctAnswerText = app.activeDocument.layers.getByName('CorrectAnswer').textItem.contents;
if(app.activeDocument.layers.getByName('Answer1').textItem.contents == correctAnswerText) app.activeDocument.layers.getByName('Answer1').textItem.color = correctAnswerColor;
if(app.activeDocument.layers.getByName('Answer2').textItem.contents == correctAnswerText) app.activeDocument.layers.getByName('Answer2').textItem.color = correctAnswerColor;
if(app.activeDocument.layers.getByName('Answer3').textItem.contents == correctAnswerText) app.activeDocument.layers.getByName('Answer3').textItem.color = correctAnswerColor;
if(app.activeDocument.layers.getByName('Answer4').textItem.contents == correctAnswerText) app.activeDocument.layers.getByName('Answer4').textItem.color = correctAnswerColor;