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

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

Contributor ,
Jul 03, 2019 Jul 03, 2019

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
3.0K
Translate
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…

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

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

Translate
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

download is not available?

Translate
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

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

Translate
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

Screen Shot 2019-07-03 at 1.06.18 PM.pngfailed no file?

Translate
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

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.

Translate
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

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

Translate
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

Does this work with CC2018? seems to not

Translate
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

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;

}

Translate
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

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

Translate
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

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

Translate
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

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

Translate
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

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

Translate
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

where is the newer version ?

Translate
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

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!

Translate
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

Just send you a PM…

Translate
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

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

Translate
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

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.

Translate
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

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

Translate
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
LATEST

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

Translate
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

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

Translate
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
Translate
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

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

Translate
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