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

Randomly assign character styles

Participant ,
Jan 04, 2019 Jan 04, 2019

Copy link to clipboard

Copied

This might sound counterintuitive, but I would like to randomly assign character styles to chunks of text.

Either to apply colour in a random way (a bit like repeating nested character styles as shown in the screenshot below— but looser) or as a way of applying 'natural' micro-tweaks to my typesetting, for example if I was to mimic how Letraset  / rubdown type would be applied wonkily...

There are lots of scripts that let me apply random variations to attributes such as character baseline, rotation etc such as Scribbler.

— but I would potentially want to randomly apply a different font via a character style, for instance...

I am essentially looking for a 'random' function for nested styles, rather than 'repeat' as shown here...

thanks as ever for your time and advice!

Screen Shot 2019-01-04 at 22.28.46.png

Views

2.5K

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 , Jan 05, 2019 Jan 05, 2019

Well, just a try. Paragraph style has its own color (dark blue here). Additional colors added via GREP, seems quite random to me. Appearance can be adjusted by adding/removing dots at  the beginning of each regex, also changing styles order.

randomcolor.png

Votes

Translate

Translate
Community Expert ,
Jan 04, 2019 Jan 04, 2019

Copy link to clipboard

Copied

With any rule, GREP or nested styles you will get regular applied character styles. Therefore you have manually apply randomly Character Styles.

Those rule might help you to get a sound basis to begin with.

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 ,
Jan 05, 2019 Jan 05, 2019

Copy link to clipboard

Copied

Well, just a try. Paragraph style has its own color (dark blue here). Additional colors added via GREP, seems quite random to me. Appearance can be adjusted by adding/removing dots at  the beginning of each regex, also changing styles order.

randomcolor.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
Participant ,
Jan 07, 2019 Jan 07, 2019

Copy link to clipboard

Copied

Hey! This is great, more than adequate for simulating randomness, but thanks!

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 ,
Jan 06, 2019 Jan 06, 2019

Copy link to clipboard

Copied

Also, if winterm​'s Grep doesn't work for you try this AppleScript.

Put the Character Styles you want to randomly apply in a group folder named Random Characters, select the text, and run this script:

tell application "Adobe InDesign CC 2018"

    set g to every character style group of active document whose name is "Random Characters"

    set a to every character style of every character style group of active document whose parent is item 1 of g

    set c to object reference of every character of selection

    repeat with x in c

        try

            set rn to (random number from 1 to count of a)

            set applied character style of x to item rn of a

        end try

    end repeat

end tell

Styles can be named anything—they just have to be in the Random Characters group

Screen Shot 10.png

Here's a similar script for applying random color swatches to a selection from a swatches group named Random Colors:

tell application "Adobe InDesign CC 2018"

    set g to every color group of active document whose name is "Random Colors"

    set a to every swatch of active document whose parent color group is item 1 of g

    set c to object reference of every character of selection

    repeat with x in c

        set rn to (random number from 1 to count of a)

        set fill color of x to item rn of a

    end repeat

end tell

Screen Shot 11.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
Participant ,
Jan 07, 2019 Jan 07, 2019

Copy link to clipboard

Copied

LATEST

And this implementation seems to do the trick too, many thanks!!

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