Converting between autofollow/continue runs and timeline groups

135 views
Skip to first unread message

James Lo

unread,
Aug 30, 2023, 1:14:00 PM8/30/23
to QLab
For fun, I wrote a pair of not-very-bullet-proof scripts to convert a run of autofollow/continue cues into a timeline group and vice versa.  In the former case you must select a set of top level cues that contain the entire run or runs you wish to convert, and in the latter case you select a set of cues that contain the groups you want to convert, but not the group's children.  (Sorry about that, I'll revisit these complicated prerequisites later.  In the meantime I hope that they deter anyone from trying these scripts on a real show)  Note that these scripts taken as a pair do not consistently undo each other, for instance a run with an autofollow that is grouped then ungrouped will not contain autofollows.

It appears that my scripts mess up Qlab's undo memory, i.e. after I run them, repeated Command-Zs will not restore the workspace to its original state.  It might be related to how I'm moving cues but I'm really not sure.  Is it something in my scripts?

autorun -> timeline group:

set inRun to false


tell application id "com.figure53.QLab.5" to tell front workspace

set selectedCues to (selected as list)

repeat with eachcue in selectedCues

if the continue mode of eachcue is do_not_continue then

if inRun is true then --this is the last cue in the run of autocontinue/follows

set inRun to false

set thisPreWait to pre wait of eachcue

set pre wait of eachcue to accumWait + thisPreWait

set post wait of eachcue to 0

move cue id (uniqueID of eachcue) of (parent of eachcue) to end of newGroup

end if

else

if inRun is false then --this is the first cue in the run of autocontinue/follows

set inRun to true

set accumWait to 0

--create the group.  It will temporarily be after the first cue in the auto run

set tempSelection to {}

copy eachcue to end of tempSelection

set selected to tempSelection

make type "Group"

set newGroup to last item of (selected as list)

set mode of newGroup to timeline

end if

set thisPreWait to pre wait of eachcue

set pre wait of eachcue to accumWait + thisPreWait

if the continue mode of eachcue is auto_follow then

set thisPostWait to duration of eachcue

else

set thisPostWait to post wait of eachcue

end if

set post wait of eachcue to 0

move cue id (uniqueID of eachcue) of (parent of eachcue) to end of newGroup

set accumWait to accumWait + thisPreWait + thisPostWait

end if

end repeat

set selected to selectedCues

end tell



from autorun.png
to timeline.png
timeline group -> autorun:

tell application id "com.figure53.QLab.5" to tell front workspace

set selectedCues to selected as list

repeat with eachGroup in selectedCues

if q type of eachGroup is "Group" and mode of eachGroup is timeline then

set sortedChildren to my sortCues(cues of eachGroup as list)

set lastPrewait to 0

set eachGroupUniqueID to uniqueID of eachGroup

set eachGroupParent to parent of eachGroup

repeat with eachCue in sortedChildren

--compute the new prewait

set currentPrewait to pre wait of eachCue

set newPrewait to currentPrewait - lastPrewait

--move the cue

move cue id (uniqueID of eachCue) of eachGroup to before cue id (eachGroupUniqueID) of eachGroupParent

--assign the new prewait

set pre wait of eachCue to newPrewait

set post wait of eachCue to 0

set continue mode of eachCue to auto_continue

set lastPrewait to currentPrewait

end repeat

set continue mode of eachCue to do_not_continue --fix the continue mode of the last cue in the run

delete cue id (eachGroupUniqueID) of eachGroupParent

end if

end repeat

end tell



on sortCues(cueList)

tell application id "com.figure53.QLab.5" to tell front workspace

set theIndexList to {}

set theSortedList to {}

repeat (length of cueList) times

set theLowItem to ""

repeat with a from 1 to (length of cueList)

if a is not in theIndexList then

set theCurrentItem to item a of cueList

if theLowItem is "" then

set theLowItem to theCurrentItem

set theLowItemIndex to a

else if pre wait of theCurrentItem < pre wait of theLowItem then

set theLowItem to theCurrentItem

set theLowItemIndex to a

end if

end if

end repeat

set end of theSortedList to theLowItem

set end of theIndexList to theLowItemIndex

end repeat

return theSortedList

end tell

end sortCues

from timeline.png

to autorun.png


test AppleScript timelines.qlab5
test AppleScript groups.qlab5
Message has been deleted

James Lo

unread,
Aug 31, 2023, 2:40:44 PM8/31/23
to QLab
Here are minimal examples that exhibit the same undo issue.  First, group creation:

tell application id "com.figure53.QLab.5" to tell front workspace

set selectedCues to (selected as list)

set tempSelection to {}

copy item 1 of selectedCues to end of tempSelection

set selected to tempSelection

make type "Group"

set newGroup to last item of (selected as list)

repeat with eachcue in selectedCues

move cue id (uniqueID of eachcue) of (parent of eachcue) to end of newGroup

end repeat

end tell

I start with a single note cue
from one note.png
Then run the script
to grouped note.png
Then press Command-z once
undo once.png
And Command-z a second time
undo twice.png






workspace w one note.qlab5

James Lo

unread,
Aug 31, 2023, 2:44:46 PM8/31/23
to QLab
For ungrouping

tell application id "com.figure53.QLab.5" to tell front workspace

set selectedCues to selected as list

repeat with eachGroup in selectedCues

if q type of eachGroup is "Group" and mode of eachGroup is timeline then

repeat with eachCue in cues of eachGroup as list

move cue id (uniqueID of eachCue) of eachGroup to before cue id (uniqueID of eachGroup) of (parent of eachGroup)

end repeat

end if

end repeat

end tell

I start with a single group with one child cue
from group.png
and run the script






to run.png
When I undo twice I get
undo to empty group.png
workspace w one group.qlab5

Rich Walsh

unread,
Sep 1, 2023, 6:21:25 AM9/1/23
to ql...@googlegroups.com
The AppleScript move command is awkward and doesn’t end up in the undo stack; it doesn’t have a direct analogy in the UI commands…

This will demonstrate:

tell application id "com.figure53.QLab.5" to tell front workspace to move cue id (uniqueID of first cue of current cue list) of current cue list to end of current cue list


Trying to undo it will delete the cue you moved.

It’s a feature.

Rich

On 31 Aug 2023, at 19:44, James Lo <revers...@gmail.com> wrote:

For ungrouping
tell application id "com.figure53.QLab.5" to tell front workspace
set selectedCues to selected as list
repeat with eachGroup in selectedCues
if q type of eachGroup is "Group" and mode of eachGroup is timeline then
repeat with eachCue in cues of eachGroup as list
move cue id (uniqueID of eachCue) of eachGroup to before cue id (uniqueID of eachGroup) of (parent of eachGroup)
end repeat
end if
end repeat
end tell
I start with a single group with one child cue
<from group.png>
and run the script






<to run.png>
When I undo twice I get
-- 
Contact support anytime: sup...@figure53.com
Follow QLab on Twitter: https://twitter.com/QLabApp
User Group Code of Conduct: https://qlab.app/code-of-conduct/
--- 
You received this message because you are subscribed to the Google Groups "QLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qlab+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qlab/01c8f0e7-7a1a-4b6a-8e6a-5d9f114a328fn%40googlegroups.com.
<from group.png><to run.png><workspace w one group.qlab5><undo to empty group.png>

James Lo

unread,
Sep 1, 2023, 7:43:04 AM9/1/23
to QLab
Wow, you really found the minimal example, thanks!  Unfortunately I went back and tried yours and my (so-called) minimal examples with Qlab 4 and Qlab 3 and undo works as expected, so I think it may be a real issue with Qlab 5.

James Lo

unread,
Sep 1, 2023, 9:22:50 AM9/1/23
to QLab
Hmm, but the example script "Create and Move a New Cue" from https://qlab.app/docs/v5/scripting/examples/ can be undone.  I wonder how it differs?

Rich Walsh

unread,
Sep 1, 2023, 12:01:10 PM9/1/23
to ql...@googlegroups.com
I’m not seeing that: if I run that script and then undo, the newly-created Memo Cue does vanish – but the undo menu now has “Undo Create 1 Memo Cue” as the next undo. It looks like it’s working as the first undo makes a cue vanish – but that’s not what it should do: it should move the Memo Cue back to outside the Group Cue.

Incidentally, in that example script this line is unnecessarily complex:

set theGroup to the first cue whose q number is theGroupNumber


This works just as well as by definition there can only be precisely ONE cue whose q number has a given value:

set theGroup to cue theGroupNumber


I’d probably trap that as well, in case said cue doesn’t exist…

Good spot that it used to work in v4; I didn’t go back to check.

Rich

micpool

unread,
Sep 1, 2023, 12:53:08 PM9/1/23
to QLab
It's not different,

It restores the workspace back to the state it was before the script was run, but it only does that because it destroys the cue the script made before it  moved it.

Normally when a script is run, each action the script performs ends up as an individual item on the undo stack.

I agree though that the destruction of undone moved cues (by script) only started with QLab 5, so you could report that as a bug, through the support item on the help menu.

Mic
Reply all
Reply to author
Forward
0 new messages