Copy link to clipboard
Copied
Hello!
I'd like to create a script that can select a random character in my story and can then apply a character style to that selection.
It would be great if I could choose the "amount" of randomness... for example I could assert that 30% or 80% of all the characters can be changed to the character style.
I found this other post but haven't had any luck running this script.
https://community.adobe.com/t5/indesign/randomly-assign-font-to-characters/m-p/11473695?page=1#M3980...
Thank you!
Copy link to clipboard
Copied
Hi Anna,
what did you try so far with your own coding in ExtendScript?
You could try this with method anyItem() of the characterStyles collection of a document.
To demonstrate this, run the following script snippet on selected text:
app.selection[0].appliedCharacterStyle = app.documents[0].characterStyles.anyItem();
Run it more than one time and observe if the applied character style will change.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Hi! Thanks for helping
So I applied this to all of my text and the character style was applied to the entire selection. How can I tell InDesign to randomly pick letters?
Copy link to clipboard
Copied
However, if you want only quasi-randomness, where I'm not sure what that means, you could perhaps include a counter that checks how often the same style is used and repeat the action if the styles are not used often enough.
Or you could limit the characters in a given range of characters that should be changed. Hm. So, please explain exactly what you expect from an "amount" of randomness that affects 30% or 80% of all the characters. How many changes should happen e.g. in a text with 100 characters? Should white space characters be involved as well?
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
It would be great if out of 100 characters, only 30% would be changed to italics. However, those 30 letters would have to be chosen randomly throughout the entire text, which is 100 characters.