Automatically Generate Multi Line Titles with different formatting per line from text file and template cue.

249 views
Skip to first unread message

micpool

unread,
May 8, 2021, 1:41:44 PM5/8/21
to QLab
Finally got round to doing some more work on my titling workspace.

The attached will import text from an open text edit document with each paragraph of the text edit file making a cue and forward slashes in each paragraph indicating line breaks.

Instead of having to painstakingly set all the text parameters in the script, all the formatting is copied from a template cue in the workspace numbered TEXTPLATE. This is actually more complex to do than it sounds as the formatting is contained in a text format record for the entire cue with range offsets and lengths which are tricky to calculate as there are often a lot more items in the record than there are lines of text. I finally realised that however the ranges in the record are split up, there is always a new record item at the beginning of every line, so I have just set the formatting for each line of the generated text cues from the formatting of the first character of each line in the template cue. 

The screen recording should give you a good idea of whats going on. There's rather a lot of scripting so I won't paste it here, but there are 2 scripts at the top of the cue list of the attached workspace

It's by no means finished or tested, but may form a good basis for your future titles and lower thirds workspaces.

Mic
Subtitle importer demo.zip
Subtitles with formatting from template.mov

micpool

unread,
May 10, 2021, 10:09:36 AM5/10/21
to QLab
Sorry there is a major flaw in the above workspace. It works as long as the lines in the template are not identical in every aspect of their text formatting

 I had assumed that a new record item was created for each line of a text cue, but if 2 or more  lines have identical formatting this is not the case.

 I am trying to fix this by duplicating text records in a list of text records, so that there is always one record per line in the text record of the template , ready to apply to the text cues

However there is obviously something I don't understand about lists and records as when I change a property of one item of a record it is changing in all the duplicated items in the list.

Here is the problem simplified

This works:

set therecord to {{A:1}, {A:1}}

set A of item 2 of therecord to 6

return therecord

--result {{A:1}, {A:6}}


This doesn't

set therecord to {A:1}

set thenewrecord to {}

set end of thenewrecord to therecord

set end of thenewrecord to therecord

set A of item 2 of thenewrecord to 6

return thenewrecord

--result {{A:6}, {A:6}}


Any ideas what is going on here?

Thanks




Rich Walsh

unread,
May 10, 2021, 10:11:51 AM5/10/21
to ql...@googlegroups.com
I think "set" creates a reference to the same object – you need to "copy" to end.

Rich

micpool

unread,
May 10, 2021, 10:40:55 AM5/10/21
to QLab
Thanks very much Rich, that's solved the problem and saved me hours of head scratching.

It's another one of those annoying AppleScript things when results from different scripts e.g 


set therecord to {{A:1}, {A:1}}

return therecord

and

set arecord to {A:1}

set therecord to {}

copy arecord to end of therecord

copy arecord to end of therecord

return therecord


and

set arecord to {A:1}

set therecord to {}

set the end of therecord to arecord

set the end of therecord to arecord

return therecord



appear in script editor as identical, with no way of telling they are actually completely different.

Mic


Message has been deleted

micpool

unread,
May 11, 2021, 7:25:48 PM5/11/21
to QLab
Well, that approach didn't work at all, so I started again from scratch. The main problem was matching the range offsets and lengths in the  text  cues with the range offsets and lengths of the template cues. Quite often the new range starts on a newline character at the end of a line, and when lines have identical formatting the range extends across multiple lines. I simplified the problem by resetting the titles text cues to a simple state before mapping the template text cues and then used three main routines to cope with the various mapping combinations.

Although it's taken considerably longer than I was expecting, it's nearly there, as you can see in the attached screen recording. I've run out of time until the end of the week to test it thoroughly before posting the workspace, but here's a sneak preview.

It also might be a proof of concept that 'Fancy Paste ' could cope with multi text formats in single copied text cues?

Mic
FancyPaste MultiLine Formatting.mov
Reply all
Reply to author
Forward
0 new messages