[JW Lua] Reading measures from parts
Jan Angermüller
jan at angermueller.com
Fri May 16 19:57:57 CEST 2014
Hi Charles,
you were right - the script I posted was fully working.
The problem was somewhere else (in the ... part)
where I didn't expect it.
So now here comes the real problem.
Jari, FCPart:IsStaffIncluded(staffnumber) seems to
influence the part domains. Once you call it, you are no
longer in the part domain as you were before.
FCMeasure then also changes the score domain.
Below is the fully working script that applies
"Time Signature Spacing" to all measures in parts only (not in the score)
that contain slash style notation (as slash style notation
can't be identified at the moment, it has to be hard-coded
which is done in the first line with slashstyleID=2).
The crucial part is a second p:SwitchTo() which I had
to insert, as p:IsStaffIncluded seems to have left the part domain that
it was in before.
If you take out both p:IsStaffIncluded() and the second p:SwitchTo()
the script will work with wrong behaviour as StaffIncluded is not
checked as required,
but with correct semantics.
If you take out the second p:SwitchTo() which should actually not be
necessary at this position, the script will behave faulty:
the measures from the score (!) and the parts will be changed,
although only the measures from the parts only can be changed
(p:IsPart assures that only the parts will be changed).
Attached you also find a Finale 2012 where you can check it.
Jan
--ID of the slash notation style
local slashstyleID=2
--set region, or if nothing is selected, then select all
local region = finale.FCMusicRegion()
region:SetCurrentSelection()
if (region.StartStaff == 0) then
region:SetFullDocument()
end
local firststaff=region.StartStaff
local endstaff=region.EndStaff
local parts = finale.FCParts()
parts:LoadAll()
for p in each(parts) do -- parse all parts for its slash style measures
p:SwitchTo()
if p:IsPart() then -- parse parts only, don't parse score
for staffnumber=firststaff,endstaff,1 do -- check all staves ...
if p:IsStaffIncluded(staffnumber) then --... that appear
in this part
p:SwitchTo() -- !!!! this is the crucial part !!!!
although we have switched to the part already before,
-- we need to switch again, as
p:IsStaffIncluded seems to have influenced somehow
-- the current part domain
local StyleAssigns = finale.FCStaffStyleAssigns(staffnumber)
StyleAssigns:LoadAllForItem(staffnumber)
for SA in each(StyleAssigns) do
if SA:GetStyleID() == slashstyleID then
for j = SA.StartMeasure, SA.EndMeasure,1 do -- mark
all measures that belong
local measure=finale.FCMeasure()
measure:Load(j);
measure:SetPositioningNotesMode(finale.POSITIONING_TIMESIG)
measure:Save()
end
end
end
end
end
end
end
-------------- next part --------------
A non-text attachment was scrubbed...
Name: settotimespace.mus
Type: application/octet-stream
Size: 55169 bytes
Desc: not available
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20140516/a6844381/attachment.obj>
More information about the JWLua
mailing list