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

Looking for a Grep command or script that will alternate the baseline shift

Contributor ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

Looking for a Grep command or script that will alternate the baseline shift of every other letter in a paragraph or sentence. This is for a childrens book lettering?

TOPICS
Scripting

Views

2.1K

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

Mentor , Jul 08, 2019 Jul 08, 2019

Just send you a PM…

Votes

Translate

Translate
Mentor ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

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
Contributor ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

that is extremely helpful how do it edit it ? with brackets

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
Contributor ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

download is not available?

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
Mentor ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

Follow the link, scroll to the bottom of page, right-click on Random_Letter_Presser.jsx, choose Save Link As…

presser.png

Install the script, run it. Here's a panel window you should see:

presser2.png

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
Contributor ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

Screen Shot 2019-07-03 at 1.06.18 PM.pngfailed no 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
Participant ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

You can find the script in this link:

https://github.com/GitBruno/Novelty/tree/master/Scripts

I had problems accessing the link in Safari, but had no problems with Chrome or Edge.

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
Contributor ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

even better Screen Shot 2019-07-03 at 1.19.23 PM.png

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
Contributor ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

Does this work with CC2018? seems to not

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
Mentor ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

OK. Just copy/paste (carefully!) the code below. Warning: script works pretty slowly, test on a small amount of text first.

Tested in CC2019, works just fine.

/*

    Letter_Presser.jsx

    Version 0.2 (TEST)

    Experimental InDesign CS5 JavaScript

    Bruno Herfst 2011

    This script sets a randome baselineshift between two values

    to all text found in seleced paragraph style

    can also set random thin outlines for extra letter-press feel.

*/

#target "InDesign"

//global varialbles

var ps, cw, bls, sw;

main();

//============================================== FUNCTIONS =====================================================

function main(){

    var myDoc = app.documents.item(0);

    // Create a list of paragraph styles

    var list_of_All_paragraph_styles = myDoc.paragraphStyles.everyItem().name;

    list_of_All_paragraph_styles.unshift("All paragraph styles");

    // Make the dialog box for selecting the paragraph styles

    var dlg = app.dialogs.add({name:"LetterPresser"});

    with(dlg.dialogColumns.add()){

        with(dialogRows.add()){

            staticTexts.add({staticLabel:"Do"});

            with(myFitButtons = radiobuttonGroups.add()){

                    var c = radiobuttonControls.add( { staticLabel : 'Characters', checkedState : true } ),

                        w = radiobuttonControls.add( { staticLabel : 'Words' } );

                }

            staticTexts.add({staticLabel:" in paragraph style:"});

            var find_paragraph = dropdowns.add({stringList:list_of_All_paragraph_styles, selectedIndex:list_of_All_paragraph_styles.length-1});

        }

        with(dialogRows.add()){

            with(borderPanels.add()){

                staticTexts.add({staticLabel:"Max baselineshift:"});

                bls = 0.225;

                var myBlsField = measurementEditboxes.add({editUnits: MeasurementUnits.POINTS,editValue:bls});

                staticTexts.add({staticLabel:"Max strokewidth:"});

                sw = 0.15;

                var mySwField = measurementEditboxes.add({editUnits:MeasurementUnits.POINTS,editValue:sw});

            }

        }

        with(dialogRows.add()){

            with(dialogColumns.add()){

            }

        }

    }

    //show dialog

    if(dlg.show() == true){

        //get dialog data

        sw = mySwField.editValue,

        bls = myBlsField.editValue,

        cw = c.checkedState; // true: character, false: word

        if (find_paragraph.selectedIndex == 0) {

            ps = false;

        } else {

            ps = myDoc.paragraphStyles.item(find_paragraph.selectedIndex-1);

        }

        // Set find grep preferences to find all paragraphs with the selected paragraph style

        app.findChangeGrepOptions.includeFootnotes = false;

        app.findChangeGrepOptions.includeHiddenLayers = false;

        app.findChangeGrepOptions.includeLockedLayersForFind = false;

        app.findChangeGrepOptions.includeLockedStoriesForFind = false;

        app.findChangeGrepOptions.includeMasterPages = false;

        app.findGrepPreferences = NothingEnum.nothing;

        if(ps == false){

            app.findGrepPreferences.appliedParagraphStyle = NothingEnum.nothing;

        } else {

            app.findGrepPreferences.appliedParagraphStyle = ps;

        }

        app.findGrepPreferences.findWhat = "^.+";

        //Now let’s find the paragraphs

        //Search the current story

        var found_paragraphs = myDoc.findGrep();

        var myCounter = 0;

        var myMessage = false;

        do {

            try {

                // Create an object reference to the found paragraph and the next

                wavePara(found_paragraphs[myCounter]);

                myCounter++;

            } catch(err) {

                myMessage = err;

                myMessage = "Couldn't find anything!";

            }

        } while (myCounter < found_paragraphs.length);

        if(myMessage == false){

            var myMessage = "Done setting "+(myCounter)+" paragraphs!";

        }

        alert(myMessage);

        //the end

        dlg.destroy();

    } else {

        //cancel

    }

}

//-------------------------------------------------------------------------------------------------------------

function wavePara(myPara){

    myPara.strokeAlignment = TextStrokeAlign.CENTER_ALIGNMENT;

    var myLines = myPara.lines;

    //for lines in paragraph

    for (var line=0, ll=myLines.length; line < ll; line++){

        var myLine = myPara.lines[line];

        var cl = myLine.characters.length;

        var mod = 0;

        startValue = sw;

        //for characters in lines

        for (var character=0; character < cl; character++){

            try{

                var myCharacter = myLine.characters[character];

                myCharacter.strokeColor = "Black";

                myCharacter.baselineShift = randomInRange(0,bls);

                myCharacter.strokeWeight = randomInRange(0,sw);

            }catch(r){

                //alert(r.description);

                //This should not happen but if it does deal with it quitely

                line-=1; // redo line

                ll+=1; // in case the paragraph got longer

                // if not will break anyway

                break;

            }

        }

    }

}

//-------------------------------------------------------------------------------------------------------------

function randomInRange(start,end){

       return Math.random() * (end - start) + start;

}

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
Contributor ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

New to scripting do i paste into brackets and save as a .jsx

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
Contributor ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

Im obviously doing something wrong

i drop the script in the script panel in CC2019 ( at home now(

click on the sentence and hit run scriptScreen Shot 2019-07-03 at 6.34.16 PM.png

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 ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

I'm moving this discussion to the InDesign Scripting forum.

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
Mentor ,
Jul 04, 2019 Jul 04, 2019

Copy link to clipboard

Copied

FWIW, a newer version (1.4, post #6) offers more settings and, likely, optimized code (works a bit faster):

presser14.png

The author didn't invest much in UI, though

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
Contributor ,
Jul 08, 2019 Jul 08, 2019

Copy link to clipboard

Copied

where is the newer version ?

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
Contributor ,
Jul 08, 2019 Jul 08, 2019

Copy link to clipboard

Copied

can you email me the script? and step by step? I know how to install it but how do I use it on a paragraph?

Recordit: Record screencasts fast & free! with GIF Support!

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
Mentor ,
Jul 08, 2019 Jul 08, 2019

Copy link to clipboard

Copied

Just send you a PM…

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
Contributor ,
Jul 08, 2019 Jul 08, 2019

Copy link to clipboard

Copied

Screen Shot 2019-07-08 at 2.09.53 PM.png

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
Mentor ,
Jul 08, 2019 Jul 08, 2019

Copy link to clipboard

Copied

Works just fine in Win7/CS6, and Win10/CC2019. Here's a screenshot from CC2019, v14.02, with default script settings already applied to the first paragraph.

PresserCC2019.png

Could your problem be a Mac related? Maybe someone on Mac machine will chime in to verify.

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
Contributor ,
Jul 08, 2019 Jul 08, 2019

Copy link to clipboard

Copied

Im running Mac 10.16.6 High Seirra on a Mac Book Pro with CC2018/2019?

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
Contributor ,
Jul 09, 2019 Jul 09, 2019

Copy link to clipboard

Copied

LATEST

thank you winterm​ all I needed was a good reeboot!

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
Mentor ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

New to scripting ...

copy / paste the code into plain text editor (like Notepad on Windows). There must be no formatting, just plain text!

Change file extension from txt to jsx.

here's how to install:

https://indesignsecrets.com/how-to-install-scripts-in-indesign.php

do i paste into brackets

not sure what do you mean

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 ,
Jul 04, 2019 Jul 04, 2019

Copy link to clipboard

Copied

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
Mentor ,
Jul 04, 2019 Jul 04, 2019

Copy link to clipboard

Copied

Oh, very likely. However, anything more than a plain text editor is a bit overkill in this case.

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