Need help with Applescript

139 views
Skip to first unread message

NCSLLC

unread,
Mar 10, 2021, 3:09:35 PM3/10/21
to QLab
Hi,

Wanted to reach out to the community to help me with some issues I'm having with applescript. I have been trying to use multiple target and arm cues to retarget multiple start cues to target the same audio cue, then arm those start cues.

I'ts been brought to my attention that I can seriously reduce the number of cues I'm using by using a script cue instead. I know I can use the script

set cue target of cue "A1" to cue "audio1"
set armed of cue "A1" to true

and just repeat these 2 lines for however many cues I need to retarget and arm. However I think there may be an easier way  for me to do this by using a repeat loop, which is where I'm stuck.

tell application id "com.figure53.QLab.4" to tell front workspace
    set cueNameList to {""}
    set currentCueName to ""
    repeat with currentChar in notes of cue "cueTargets" as string
        if currentChar = "," then
            set cueNameList to cueName & currentCueName
            set currentCueName to ""
        else
            set currentCueName to currentCueName & currentChar
            say currentCueName
        end if
    end repeat
end tell

Is the code I'm currently working with. It gets the names of the cue from the notes section of a memo cue with the cue number "cueTargets".  All the cues there are listed separated by a comma (e.g. A1,A2,B3,H8)

Ideally what I want to be able to do is have a script retarget and rearm quickly without me having to write 2 lines for each cue. I'm sure the people here who have a lot more experience than I do coding and with Qlab can probably point out that I'm overlooking some very simple and effective way to do what I want. If you know please help!

Thanks

micpool

unread,
Mar 10, 2021, 3:48:13 PM3/10/21
to QLab
Hi Nicholas,

It might be worth backing up one step and just describing in non technical terms the problem in your workspace you are attempting to solve.

This might not be the case here, but often when people ask a question about a script ,where it is not clear what task it is meant to solve , the script that doesn't work is sometimes not the best approach to the problem in the first place!

Mic

NCSLLC

unread,
Mar 11, 2021, 2:34:49 PM3/11/21
to QLab
What I'm trying to do is retarget and rearm multiple cues simultaneously.

For example:

I am trying to retarget these cues to an audio cue with the cue number intro. Then rearm all these cues.

I know I can do the following:
however this causes my project to go up in the thousands in terms of number of cues. Since I need to retarget and rearm multiple cues multiple times throughout my project.

I was told to cut down on the number of cues I can replace all of these cues with a single script cue. I could just write a script that says:

set cue target of cue "A1" to cue "intro"
set cue target of cue "A2" to cue "intro"
set cue target of cue "A3" to cue "intro"
set cue target of cue "A4" to cue "intro"
set cue target of cue "A5" to cue "intro"
set cue target of cue "A6" to cue "intro"
set cue target of cue "A7" to cue "intro"
set cue target of cue "A8" to cue "intro"
set armed of cue "A1" to true
set armed of cue "A2" to true
set armed of cue "A3" to true
set armed of cue "A4" to true
set armed of cue "A5" to true
set armed of cue "A6" to true
set armed of cue "A7" to true
set armed of cue "A8" to true

but I'm wondering if anyone knows of a cleaner way to write a script that does this.

NCSLLC

unread,
Mar 11, 2021, 2:35:11 PM3/11/21
to QLab
Screen Shot 2021-03-11 at 2.19.17 PM.pngScreen Shot 2021-03-11 at 2.20.53 PM.png

NCSLLC

unread,
Mar 11, 2021, 2:36:17 PM3/11/21
to QLab
Sorry, for some reason these images were preventing me from posting my reply.

The first image is the cues I'm trying to retarget and rearm.
Second image is what I am currently doing, but trying to find a script cue to consolidate.

Sam Kusnetz

unread,
Mar 11, 2021, 2:52:28 PM3/11/21
to QLab
I was told to cut down on the number of cues I can replace all of these cues with a single script cue. I could just write a script that says:

set cue target of cue "A1" to cue "intro"
set cue target of cue "A2" to cue "intro"
set cue target of cue "A3" to cue "intro"
set cue target of cue "A4" to cue "intro"
set cue target of cue "A5" to cue "intro"
set cue target of cue "A6" to cue "intro"
set cue target of cue "A7" to cue "intro"
set cue target of cue "A8" to cue "intro"
set armed of cue "A1" to true
set armed of cue "A2" to true
set armed of cue "A3" to true
set armed of cue "A4" to true
set armed of cue "A5" to true
set armed of cue "A6" to true
set armed of cue "A7" to true
set armed of cue "A8" to true

but I'm wondering if anyone knows of a cleaner way to write a script that does this.

Assuming you don’t have other “A-something” cues, you can do this pretty easily with two OSC commands:

/cue/A*/target “intro”
/cue/A*/armed 1

Perhaps you could just create a Group cue, put two Network cues inside that send those two commands, and then use that Group cue in place of your Script cue?

-Sam

––
Sam Kusnetz [he/him/his] (what is this?)
Figure 53
https://qlab.app | https://figure53.com
 --
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/9945e05d-eceb-4e07-ad3e-88bcc7237d59n%40googlegroups.com.

micpool

unread,
Mar 11, 2021, 3:07:48 PM3/11/21
to QLab
Isn't the required  OSC
/cue/A*/cueTargetNumber “intro”

I was just about to reply along similar lines, but the point of my original question was really to ask the purpose of so many cues with identical targets. If Nicholas gave us some more general information about the project he is   programming, there may be a better overall  workspace structure to achieve the same thing without  'thousands of cues'

Mic


Sam Kusnetz

unread,
Mar 11, 2021, 3:54:53 PM3/11/21
to QLab
Oof, that’s what I get for moving between too many projects too quickly.

Yes, Mic is correct, the OSC command to set targets should be /cue/A*/cueTargetNumber “intro"

Thanks, Mic!

Sam

––
Sam Kusnetz [he/him/his] (what is this?)
Figure 53
https://qlab.app | https://figure53.com

micpool

unread,
Mar 11, 2021, 4:04:42 PM3/11/21
to QLab
Leaving aside why!

This an amended version of the  script in your first post that works 

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

set cueNameList to {""}

set currentTIDs to AppleScript's text item delimiters

set currentCueName to ""

set thecuetargets to notes of cue "cueTargets"

set AppleScript's text item delimiters to ","

repeat with theitem from 1 to count of text items of thecuetargets

say text item theitem of thecuetargets

end repeat

set AppleScript's text item delimiters to currentTIDs

end tell

On Wednesday, March 10, 2021 at 8:09:35 PM UTC NCSLLC wrote:
Reply all
Reply to author
Forward
0 new messages