Skip navigation
IgnorantTurtle
Currently Being Moderated

Indesign CS5 // GREP // Help with Alternating Paragraph  Coloring Script

Jul 25, 2012 11:49 AM

Tags: #indesign #grep #name #scripts #lists #automated #directory #paragraphs #coloring

Hello All !

 

Last year I posted a question in this Forum

http://forums.adobe.com/message/3816400#3816400

{Whoops I posted the wrong link earlier it's fixed now}

and now I have to re-create the same list effect.

 

The following script was written by John Hawkinson


var i, p;
for (i=0; i<app.selection[0].paragraphs.length; i++) {
  p = app.selection[0].paragraphs[i];
  if (i%3 === 2) { p.fillTint = 50; }
  if (i%2 === 1) { p.fillTint = 30; }
}

 

innitialy the list of names is set with returns between each name like-so:  List A.png

 

When I color them with the script it works great:Screen shot 2012-07-25 at 2.10.47 PM.png

but when I find and replace space for ^p the effect remains on roughly a line and half of names. (Up until the name 'Robert Bernardini' ).

Screen shot 2012-07-25 at 2.14.04 PM.png

A few things I can't understand are:

1. If I delete the ^P manualy the color effect stays.

2. in last years list it works for the entire text box no matter what I do to the ^P's

the whole text box stays colored.

3. why does it stop working in the middle of the second line.

 

Last years working list:

 

Screen shot 2012-07-25 at 2.19.25 PM.png

 

Any help would be super appreciated and rewarded with cheese.

Thank you everyone in advance !

 

Message was edited by: IgnorantTurtle - because he's dumb and he posted the wrong link

 
Replies
  • Currently Being Moderated
    Jul 25, 2012 12:28 PM   in reply to IgnorantTurtle

    My guess is you're not getting the overset paragraphs in your tinting script. Try:

     

    var story = app.selection[0].parentStory, i, p;
    for (i=0; i<story.paragraphs.length; i++) {
      p = story.paragraphs[i];
      if (i%3 === 2) { p.fillTint = 50; }
      if (i%2 === 1) { p.fillTint = 30; }
    }
    

     

    Jeff

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 26, 2012 12:14 PM   in reply to IgnorantTurtle

    You need to save the file as plain text. Your error messages indicates you saved it as a Rich Text File (rtf1).

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 26, 2012 2:45 PM   in reply to IgnorantTurtle
    var doc = app.activeDocument,
        story = app.selection[0].parentStory, 
        swatch1 = doc.swatches.item("red"),
        swatch2 = doc.swatches.item("blue"),
        swatch3 = doc.swatches.item("yellow"), 
        i, p;
      
    for (i=0; i<story.paragraphs.length; i++) {
      p = story.paragraphs[i];
      p.fillColor = swatch1;
      if (i%3 === 2) { p.fillColor = swatch2; }
      if (i%2 === 1) { p.fillColor = swatch3; }
    }
    

     

    Change "red," "blue," etc. to the names of your swatches.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points