Hi @Theo331728749dq2 , A scripting solution might be this—expects a text frame with the applied object style to be selected:
var min = 3
var max = 5
//a selected text frame
var s = app.activeDocument.selection[0];
//random number for forced line break
var rn = Math.floor(Math.random() * (max - min + 1) ) + min;
if (s.constructor.name == "TextFrame") {
//the selected frame’s object style
var os = s.appliedObjectStyle;
var api = app.activeDocument.allPageItems;
var tf, ii;
for (var i = 0; i < api.length; i++){
//get all text frames with the same style
if (api[i].constructor.name == "TextFrame" && api[i].appliedObjectStyle == os){
tf = api[i];
//clear any existing force line breaks
if (tf.lines[0].characters[-1].contents == SpecialCharacters.FORCED_LINE_BREAK) {
tf.lines[0].characters[-1].contents = ""
}
//insert line break
var ip = tf.lines[0].words[rn].insertionPoints[0]
ip.contents = SpecialCharacters.FORCED_LINE_BREAK;
}
};
}