I'm sharing my first substantial AppleScript script in case someone finds it useful or interesting. I haven't seen anyone use recursive handlers with Qlab and it occurred to me that they would be ideal for traversing nested groups if you needed to know the nesting structure.
global selectedCues
global nrSelected
global currentIndex
set majorCueNumber to 1 -- the number you want assigned to the first cue of the selection
tell application id "com.figure53.QLab.5" to tell front workspace
set selectedCues to selected as list
set nrSelected to count of selectedCues
set currentIndex to 1
--renumber top-level cues
repeat while currentIndex <= nrSelected
set currentCue to item currentIndex of selectedCues
set q number of currentCue to majorCueNumber
set currentIndex to currentIndex + 1
if q type of currentCue is "Group" then
my scanGroup(currentCue, majorCueNumber, 1)
else if continue mode of currentCue is not do_not_continue then
my scanContiguousAuto(majorCueNumber, 1)
end if
set majorCueNumber to majorCueNumber + 1
end repeat
end tell
--recursively scan group heirarchy and assign cue numbers to reflect nesting depth
on scanGroup(groupCue, prefix as text, minorCueNumber as integer)
tell application id "com.figure53.QLab.5"
repeat while currentIndex <= nrSelected
set currentCue to item currentIndex of selectedCues
if parent of currentCue is not groupCue then
return
end if
set q number of currentCue to prefix & "." & (minorCueNumber as text)
set currentIndex to currentIndex + 1
if q type of currentCue is "Group" then
my scanGroup(currentCue, prefix & "." & (minorCueNumber as text), 1)
end if
set minorCueNumber to minorCueNumber + 1
end repeat
end tell
end scanGroup
--treat contiguous blocks of autofollow/continue as a group for numbering
on scanContiguousAuto(prefix as text, minorCueNumber as integer)
tell application id "com.figure53.QLab.5"
repeat while currentIndex <= nrSelected
set currentCue to item currentIndex of selectedCues
set q number of currentCue to prefix & "." & (minorCueNumber as text)
set currentIndex to currentIndex + 1
if continue mode of currentCue is do_not_continue then
return
end if
set minorCueNumber to minorCueNumber + 1
end repeat
end tell
end scanContiguousAuto
Before:
After: