Modify property in score, but not in parts

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Modify property in score, but not in parts

Thomas Weber

Dear all,

I'd appreciate some advice concerning the following:

If I want to modify a BarObject's property (like Dx) in the score, but not in the part, how could I do that? I have some ideas how to do it, but please "interrupt me" if I'm thinking too complicatedly. My plan would have been:

  • Keep the value of the property from the part in a variable
  • Modify the property in the score
  • Set the property in the part back to the value of the variable

Now, the tricky part seems to be finding the object(s) in the part(s) that correspond(s) to the object in the score. I think the following approach would work, but feels pretty cumbersome:

  • Loop through all Staffs in all parts and check whether their (Short|Full|)InstrumentName is identical to the Staff in the score our object is on
  • Go to the object's Bar on that Staff
  • Find out the object's index within the Bar in the score (e.g. by counting the PreviousItem()s)
  • Get the NthBarObject() in the Bar in the part

My programmer's self doesn't like that search approach for multiple reasons:

  • The search loop might find the wrong object if there are multiple instruments of the same name (e.g. in works for multiple choirs, each with Soprano, Alto, etc.)
  • Runtime presumably increases quadratically with the number of staffs, parts and items per bar
  • It feels extremely inefficient in general

Any way to do this more elegantly? (I might be missing something obvious - or not.)

With many thanks
Thomas Weber

P.S.: This is my first post to this list. For a very brief introduction, see the footer ;-).


-- 

Notengrafik Berlin GmbH
HRB 15007

UstID: DE 289234097
Geschäftsführer:
Thomas Weber und Werner J. Wolff

fon: +49 30 220661685

Leuschnerdamm 13
10999 Berlin

notengrafik.com

_______________________________________________
Plugin-dev mailing list
[hidden email]
https://avid-listsrv1.avid.com/mailman/listinfo/plugin-dev
Reply | Threaded
Open this post in threaded view
|

Re: Modify property in score, but not in parts

Alexander Plötz

It’s a long time since I did this, but I seem to remember that my general approach was this: store the current selection, clear the selection, select the object in question, cycle through all relevant parts and check whether the selection is empty (if the object is in the part, it will still be selected after a part switch), make the property changes in the appropriate part(s), switch back to the original part, restore the selection. Sometimes variations might be more suited, according to the task at hand. At some point I had outsourced this into several library methods; for example, I recall that I have a method called GetAllPartsContainingThisObject(), or something to that effect, along with a few others that break such operations down into convenient tools.

 

Alex

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Thomas Weber
Sent: Dienstag, 30. Mai 2017 22:39
To: [hidden email]
Subject: [Plugin-dev] Modify property in score, but not in parts

 

Dear all,

I'd appreciate some advice concerning the following:

If I want to modify a BarObject's property (like Dx) in the score, but not in the part, how could I do that? I have some ideas how to do it, but please "interrupt me" if I'm thinking too complicatedly. My plan would have been:

·                     Keep the value of the property from the part in a variable

·                     Modify the property in the score

·                     Set the property in the part back to the value of the variable

Now, the tricky part seems to be finding the object(s) in the part(s) that correspond(s) to the object in the score. I think the following approach would work, but feels pretty cumbersome:

·                     Loop through all Staffs in all parts and check whether their (Short|Full|)InstrumentName is identical to the Staff in the score our object is on

·                     Go to the object's Bar on that Staff

·                     Find out the object's index within the Bar in the score (e.g. by counting the PreviousItem()s)

·                     Get the NthBarObject() in the Bar in the part

My programmer's self doesn't like that search approach for multiple reasons:

·                     The search loop might find the wrong object if there are multiple instruments of the same name (e.g. in works for multiple choirs, each with Soprano, Alto, etc.)

·                     Runtime presumably increases quadratically with the number of staffs, parts and items per bar

·                     It feels extremely inefficient in general

Any way to do this more elegantly? (I might be missing something obvious - or not.)

With many thanks
Thomas Weber

P.S.: This is my first post to this list. For a very brief introduction, see the footer ;-).

 

-- 
 
Notengrafik Berlin GmbH
HRB 15007
 
UstID: DE 289234097
Geschäftsführer:
Thomas Weber und Werner J. Wolff
 
fon: +49 30 220661685
 
Leuschnerdamm 13
10999 Berlin
 
notengrafik.com

_______________________________________________
Plugin-dev mailing list
[hidden email]
https://avid-listsrv1.avid.com/mailman/listinfo/plugin-dev
Reply | Threaded
Open this post in threaded view
|

Re: Modify property in score, but not in parts

Thomas Weber
Am 31.05.2017 um 03:16 schrieb notenlektorat:

store the current selection, clear the selection, select the object in question, cycle through all relevant parts and check whether the selection is empty (if the object is in the part, it will still be selected after a part switch), make the property changes in the appropriate part(s), switch back to the original part, restore the selection.

 



That sounds really sensible, more efficient and less complicated.  Many thanks for this!

Grüße
Thomas



-- 

Notengrafik Berlin GmbH
HRB 15007

UstID: DE 289234097
Geschäftsführer:
Thomas Weber und Werner J. Wolff

fon: +49 30 220661685

Leuschnerdamm 13
10999 Berlin

notengrafik.com

_______________________________________________
Plugin-dev mailing list
[hidden email]
https://avid-listsrv1.avid.com/mailman/listinfo/plugin-dev