Offset/pos values of slurs always return 0?
In my tests so far, I’ve found that slur.offsetX, slur.offsetY, slur.posX and slur.posY all return 0, regardless of what the 'Offset' values in the Properties pane read. (I've checked that my variable slur contains a valid slur object).
Anyone know how to get the offset measurements of a slur?
Comments
I think you are looking for these properties: slurUoff1, slurUoff2, slurUoff3, slurUoff4, which contain a QPoint value (e.g. slurUoff1.x, slurUoff1.y) that refers to changing the individual 'handles' of a slur; offsetX and offsetY concern the 'overall' displacement of a slur.
In reply to I think you are looking for… by ILPEPITO
If this is not the case, your question is not very clear to me... if I move the entire slur the 'offset' and 'pos' values do not return 0...
In reply to If this is not the case,… by ILPEPITO
Oh, weird. There must be something wrong in my code... I will look into it.
In reply to Oh, weird. There must be… by michaelnorris
The explanation could be this: if you select the score with the 'blue rectangle' the slurs are identified as a 'Tie' element (number 28) and do not allow access (not even read) to the offset/pos properties (or rather they do not detect them). Access is only possible (read/write) with individual selections (the item found is 'Tie_Segment'). I'm just guessing... It's up to you to say if that's the problem.
In reply to The explanation could be… by ILPEPITO
For the sake of precision, I will add that, of course, for 'slur' and 'slur_segment' it is the same thing...
In reply to For the sake of precision, I… by ILPEPITO
Just circling back to this, as it still doesn't seem to be working.
I have a slur now, which is valid (spannerTick.ticks and spannerTicks.ticks return the start and end tick of the slur). But asking for slur.slurUoff1, slur.slurUoff2, slur.slurUoff3 and slur.slurUoff4 always return 'undefined', even where the handle is definitely offset.
Here's the code:
currentSlur = slurs[currentStaffNum][currentSlurNum]; // previously saved from blue selection.elements
currentSlurEnd = currentSlur.spannerTick.ticks + currentSlur.spannerTicks.ticks;
logError("Slur started at "+currTick+" & ends at "+currentSlurEnd); // WORKS CORRECTLY
var off1 = currentSlur.slurUoff1 == undefined ? 0 : currentSlur.slurUoff1.x;
var off2 = currentSlur.slurUoff2 == undefined ? 0 : currentSlur.slurUoff2.x;
var off3 = currentSlur.slurUoff3 == undefined ? 0 : currentSlur.slurUoff3.x;
var off4 = currentSlur.slurUoff4 == undefined ? 0 : currentSlur.slurUoff4.x;
logError("Slur offs: "+currentSlur.posX+" "+currentSlur.offsetX+" "+off1+" "+off2+" "+off3+" "+off4); // ALWAYS RETURNS 0 0 0 0 0 0
In reply to Just circling back to this,… by michaelnorris
Empirically, as I have already said, I have verified that this data is only available by selecting the slurs/ties individually or with the 'select similar elements' procedure. It is illogical, but in fact this is the case.
In reply to Empirically, as I have… by ILPEPITO
😢
In reply to Empirically, as I have… by ILPEPITO
I don't have time to try it just yet, but do you think the code would work if I inserted the following lines:
curScore.selection.select(currentSlur);
var currentSlurSegment = curScore.selection.elements[0];
var uoff1x = currentSlurSegment.slurUoff1.x;
In reply to I don't have time to try it… by michaelnorris
The 'select' method argument doesn't accept anything, and the documentation isn't much help with that. So all that remains is to try... I tried with a 'Tie' and I got this wonderful message: 'Cannot select element of type Tie', and it didn't surprise me.