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!
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.
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.
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.
Copy link to clipboard
Copied
Hey! This is great, more than adequate for simulating randomness, but thanks!
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
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
Copy link to clipboard
Copied
And this implementation seems to do the trick too, many thanks!!