[JW Lua] Reading measures from parts
Jari Williamsson
jari.williamsson at mailbox.swipnet.se
Thu Jul 3 22:30:51 CEST 2014
Jan and Charles,
I'll look into the FCPart:IsStaffIncluded issue you're encountering.
One thing I noticed (not related to FCPart:IsStaffIncluded, but to
document stability) is that if you call FCPart:SwitchTo() you MUST use a
corresponding FCPart:SwitchBack() call.
Best regards,
Jari Williamsson
On 2014-05-16 19:57, Jan Angermüller wrote:
> 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
>
>
>
> _______________________________________________
> JWLua mailing list
> JWLua at jwmusic.nu
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>
More information about the JWLua
mailing list