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

Data Driven Graphics Question

New Here ,
Apr 03, 2013 Apr 03, 2013

Copy link to clipboard

Copied

So I have a CSV file for my data driven graphics, and I know how to get all of that set up and working just fine. The trouble is, I'd like to somehow do the following:

If the value of the layer named "CorrectAnswer" = a number 1 through 4 Then

     Change the fill of the text in a layer named "1", "2", "3", or "4" to #A62124

End If

I'd like to do this as a script that I can call during batch processing of the image. Anyone know if that's possible?

TOPICS
Actions and scripting

Views

567

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
Guru ,
Apr 03, 2013 Apr 03, 2013

Copy link to clipboard

Copied

You could add solidColor layers above each of your text layers and clip it to the text layer. Then you could control the visibility/color of the text with the fields in the csv file.

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
New Here ,
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

So I ended up needing to change the way I scraped the data I'm using, and this is what I need now. Any ideas or code snippets?

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

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 ,
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

Like this?

#target photoshop

var strtRulerUnits = app.preferences.rulerUnits;

var strtTypeUnits = app.preferences.typeUnits;

app.preferences.rulerUnits = Units.PIXELS;

app.preferences.typeUnits = TypeUnits.POINTS;

var docRef = app.documents.add(600, 600, 300);

// suppress all dialogs

app.displayDialogs = DialogModes.NO;

var textColor = new SolidColor;

textColor.rgb.red = 0;

textColor.rgb.green = 0;

textColor.rgb.blue = 255;

var answerColor = new SolidColor;

answerColor.rgb.red = 166;

answerColor.rgb.green = 33;

answerColor.rgb.blue = 36;

var newTextLayer1 = docRef.artLayers.add();

newTextLayer1.kind = LayerKind.TEXT;

newTextLayer1.name = "1";

newTextLayer1.textItem.contents = "Text 1";

newTextLayer1.textItem.position = Array(50, 100);

newTextLayer1.textItem.size = 12;

newTextLayer1.textItem.color = textColor;

var newTextLayer2 = docRef.artLayers.add();

newTextLayer2.kind = LayerKind.TEXT;

newTextLayer2.name = "2";

newTextLayer2.textItem.contents = "Text 2";

newTextLayer2.textItem.position = Array(50, 200);

newTextLayer2.textItem.size = 12;

newTextLayer2.textItem.color = textColor;

app.refresh()

var newTextLayer3 = docRef.artLayers.add();

newTextLayer3.kind = LayerKind.TEXT;

newTextLayer3.name = "answer";

newTextLayer3.textItem.contents = "Text " +prompt ("1 or 2", 1).toString();

newTextLayer3.textItem.position = Array(50, 300);

newTextLayer3.textItem.size = 12;

newTextLayer3.textItem.color = textColor;

newTextLayer3.visible = false;

var checkLay = prompt ("Check layers contents? (y/n)", "y");

if (checkLay == "y") {

    var Match = 0;

    if (newTextLayer1.textItem.contents == newTextLayer3.textItem.contents) {

        Match++;

        newTextLayer1.textItem.color = answerColor;

        }

    if (newTextLayer2.textItem.contents == newTextLayer3.textItem.contents) {

        Match++;

        newTextLayer2.textItem.color = answerColor;

        }

    alert (Match + " match")

    }

app.preferences.rulerUnits = strtRulerUnits;

app.preferences.typeUnits = strtTypeUnits;

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 ,
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

LATEST

You can't use logic when working with  datasets. You would need to write a macro in your spreadsheet to create the fields to your needs, then export to csv. Mike has come up with a brilliant idea so that you can select the required colour via your csv file.

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