I am trying to automate setting rehearsal marks in my score.
The following Dorico LUA script runs on my MAC, but does not update the Dorico score. I see the debug output is correct in Dorico Script console.
local app=DoApp.DoApp()
– Simulate a delay by looping for a small amount of time
function wait(seconds)
local start = os.time()
while os.time() - start < seconds do
– Do nothing, just wait
end
end
– Move directly to a specific bar and insert a rehearsal mark
function moveToBarAndInsertRehearsalMark(barNumber)
print("Moving to bar " .. barNumber)
app:doCommand([[Navigate.GotoBar]] .. " " .. barNumber)
– Wait a moment to allow the UI to update
wait(2.0) – Adjust this delay if needed
print("Inserting rehearsal mark at bar " .. barNumber)
app:doCommand([[WriteMode.CreateRehearsalMark]])
end
– Main script starts here
– Switch to Write Mode
print(“Switching to Write Mode”)
app:doCommand([[Window.SwitchToWriteMode]])
wait(2.0) – Small delay after switching modes
– Select the start of the flow (bar 1)
print(“Selecting start of the flow (bar 1)”)
app:doCommand([[WriteMode.SelectStartOfFlow]])
wait(2.0) – Small delay to allow Dorico to process the selection
– Insert rehearsal mark at bar 1
print(“Inserting rehearsal mark at bar 1”)
app:doCommand([[WriteMode.CreateRehearsalMark]])
– Move to bar 9 and insert rehearsal mark
moveToBarAndInsertRehearsalMark(9)
– Move to bar 17 and insert rehearsal mark
moveToBarAndInsertRehearsalMark(17)
print(“Script finished!”)
Debug:
Switching to Write Mode
Selecting start of the flow (bar 1)
Inserting rehearsal mark at bar 1
Moving to bar 9
Inserting rehearsal mark at bar 9
Moving to bar 17
Inserting rehearsal mark at bar 17
Script finished!
Switching to Write Mode
Selecting start of the flow (bar 1)
Inserting rehearsal mark at bar 1
Moving to bar 9
Inserting rehearsal mark at bar 9
Moving to bar 17
Inserting rehearsal mark at bar 17
Script finished!
Am I doing something wrong in LUA scripting?
Thanks in advance,
Gregg