Hey All
I need to link these two code snippets together, unable to figure out the best way of doing it
End result would read the XML, select composition and select track then create cues using the first code snippet using the keyframe data (specifically time and value)
Code to add to run for each keyframe of the selected track using keyframe value and time
repeat for all keyframes from the selected track in composition
tell application id "com.figure53.QLab.4" to tell front workspace
make type "Network"
set theNetwork to last item of (selected as list)
set patch of theNetwork to userPatch
set osc message type of theNetwork to custom
set custom message of theNetwork to (keyFrameValue)
set pre wait of theNetwork to (keyFrameTime / 60)
end tell
end repeat
Code to find in XML correct composition, track and keyframe
on run -- example
set XMLfile to (choose file) as text
tell application "System Events" to set rootElement to XML element 1 of contents of XML file XMLfile
set compSelection to (chooseItem from {} out of rootElement) -- compositions list
set trackSelection to (chooseItem from "tracks" out of compSelection)
set frameSelection to (chooseItem from "keyframes" out of trackSelection given tag:"time")
return (getElement for "value" from frameSelection)
end run
# Choose an item from a list - returns the object specifier of the choice.
# The value of the given tag (or index if empty) is used as an entry in the choice dialog.
to chooseItem from listElement out of baseElement given tag:tag : "name"
set elements to (getElement for listElement from baseElement)
set {choices, itemIndex} to {{}, 1}
repeat with anItem in elements
if tag is in {{}, "", missing value} then -- index
set end of choices to (itemIndex as text)
set itemIndex to itemIndex + 1
else -- tag
tell application "System Events" to set end of choices to value of XML element tag of anItem
end if
end repeat
set theResult to (matchChoice from choices into elements given title:"Testing")
if theResult is false then error number -128 -- cancel
return theResult
end chooseItem
# Get an XML element for the specified element or element hierarchy list (use index for list items).
# Returns the element value if it has one; returns all elements if the hierarchyList is empty.
to getElement for hierarchyList from baseElement
try
tell application "System Events"
if hierarchyList is in {{}, "", missing value} then return XML elements of baseElement -- all
set element to baseElement -- starting point
repeat with anItem in (hierarchyList as list) -- build element hierarchy
try
set anItem to anItem as integer -- index?
end try
set element to (get XML element anItem of element)
end repeat
tell (get value of element) to if it is not missing value then return it -- value
return XML elements of element -- object specifier
end tell
on error errmess number errnum -- element not found, etc
error "getElement handler error " & errnum & ":" & return & errmess
end try
end getElement
# Match choice(s) from one list into another.
# The choiceList contains items for use in the dialog, the matchList can be anything.
to matchChoice from choiceList into matchList given prompt:prompt : "", title:title : "", OKButton:OKButton : "OK", multipleItems:multipleItems : false
if matchList is {} or (count choiceList) > (count matchList) then return false -- can't match
set {dialogList, outputList, prefix} to {{}, {}, ""}
set {spacer, divider} to {character id 8203, character id 8204} -- zero width space and non-joiner
repeat with anItem in choiceList -- add indexing prefix to allow duplicates
set prefix to prefix & spacer
set the end of dialogList to (prefix & divider & anItem)
end repeat
set choices to (choose from list dialogList with title title with prompt prompt OK button name OKButton multiple selections allowed multipleItems)
if choices is not false then -- not "Cancel"
repeat with anItem in choices
set indx to (offset of spacer & divider in anItem) -- indexing characters
set the end of outputList to contents of item indx of matchList
end repeat
if not multipleItems then return first item of outputList
return outputList
end if
return false
end matchChoice
Selecting any option will automatically load the page