delete a cue with applescript

470 views
Skip to first unread message

nizer

unread,
Aug 9, 2016, 3:25:07 PM8/9/16
to QLab
probably simple fix, but can't quite get this and I am in crunch time.

tell front workspace
set midiCues to every cue whose q type is "MIDI"
set midiCuesRef to a reference to midiCues
repeat with eachCue in midiCuesRef
if q name of eachCue contains "pitch" then
delete eachCue
end if
end repeat
end tell

any help would be very appreciated…..


luckydave

unread,
Aug 9, 2016, 3:35:48 PM8/9/16
to ql...@googlegroups.com
The difference is I'm doing two things:
1) deleting the cue by "delete cue (q number of eachCue)", meaning cue number as a reference, rather than the full cue object.
2) telling the cue list to do the deleting, rather than the workspace

I also added the "application id" stuff to the tell block, just to be sure the right dictionary is in use.

tell application id "com.figure53.qlab.3" to tell front workspace

set midiCues to every cue whose q type is "MIDI"

set midiCuesRef to a reference to midiCues

repeat with eachCue in midiCuesRef

if q name of eachCue contains "pitch" then

set thisCue to q number of eachCue

set thisCueList to parent of cue thisCue

tell thisCueList

delete cue thisCue

end tell

end if

end repeat

end tell


--
luckydave
--
--
Change your preferences or unsubscribe here:
http://groups.google.com/group/qlab
 
Follow Figure 53 on Twitter: http://twitter.com/Figure53
---
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/07a9fd1b-d822-49ce-98b7-38b64d1143aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark Nizer/Neisser

unread,
Aug 9, 2016, 3:59:50 PM8/9/16
to ql...@googlegroups.com
Amazing. Thanks. 

Mark Nizer/Neisser
You received this message because you are subscribed to a topic in the Google Groups "QLab" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/qlab/0GHE4sPD7QU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to qlab+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qlab/CANrzNvwyOzRdAeQCvkUx4BA3yFepXLFGvs4S%2B16F7p7jKXGw2g%40mail.gmail.com.

micpool

unread,
Aug 9, 2016, 4:08:26 PM8/9/16
to QLab
How do you do it if the cue doesn't have a number?

Mic

luckydave

unread,
Aug 9, 2016, 4:12:07 PM8/9/16
to ql...@googlegroups.com
I was just thinking about that.

Change this line:

set thisCue to q number of eachCue

to this:

set thisCue to uniqueID of eachCue

And where you see "cue thisCue", add id, so you get "cue id thisCue". This will reference the cue by its unique ID, which every cue has, is unique, and doesn't change. It's a better identifier than cue number for those reasons.

--
luckydave

micpool

unread,
Aug 9, 2016, 4:20:44 PM8/9/16
to QLab
The reference stuff is an unnecessary complication isn't it?

This edit of  Rich Walsh's delete script on the Wiki seems to do the trick

tell front workspace

set midicues to every cue whose q type is "MIDI" and q name contains "Pitch"

repeat with eachCue in midicues

set eachCueID to uniqueID of eachCue

delete cue id eachCueID of parent of eachCue

end repeat

end tell


Mic

micpool

unread,
Aug 9, 2016, 4:25:38 PM8/9/16
to QLab
It's probably worth adding that you shouldn't run any batch script (particularly if the word delete appears in it) on a work space  that isn't backed up!

Mic

luckydave

unread,
Aug 9, 2016, 4:48:00 PM8/9/16
to ql...@googlegroups.com
(Don't tell Mic, but I was hoping he'd swoop in here.)


--
luckydave

micpool

unread,
Aug 9, 2016, 4:59:48 PM8/9/16
to QLab
One further caveat.........

Misuse of the delete command  in a script can get you into a seemingly impossible situation where you have a workspace that contains cues and no cue lists!! You really don't want to go there! Don't try this at home!!



Mic

Rich Walsh

unread,
Aug 9, 2016, 5:14:07 PM8/9/16
to ql...@googlegroups.com
"A reference to" is noticeably faster when working with large lists, particularly if you are going to be adding items to them. I don't use this form very much any more, having overused it when I started learning AppleScript on this forum.

"delete" is an odd one (a bit like "move"). I remember it taking a lot of trial and error to figure out that the object has to be specified in relation to its direct container ("parent"). You encounter error -10006 ("Signaled when an object cannot be set in a container.") – "You cannot move/insert/remove cues referenced from a workspace. Try performing the operation referenced from their enclosing group or cue list instead."

It comes down to the fact that, for example, "last item of (selected as list)" gives you something like "cue id "1" of workspace "Workspace"" when what you need is "cue id "1" of cue id "0" of workspace "Workspace"" for Standard Suite commands… QLab Suite commands seem to be intrinsically more helpful, but I don't understand enough about object-oriented languages to explain why!

Rich

nizer

unread,
Aug 9, 2016, 8:53:36 PM8/9/16
to QLab
Watching the big dawgs chime in on this and save me hours of work is the reason I love this community so much.

Cudo's to the three of you and thanks for expanding my brain.
Reply all
Reply to author
Forward
0 new messages