I have recently been working with Capella 9 Python scripting. In my experience so far, I have discovered that drawing an object in the middle of a note head requires only passing the proper Y position into the python drawing routines. Capella apparently holds the X position of the note head internally, so no explicit X parameter need be passed into the script.
When two notes on the same stem are a second interval apart, one of the notes is placed on the opposite side of the stem for readability, however, it appears that Capella maintains the X position of that note head as if it had not been offset (which, graphically, it has). The result is that the object being drawn is in the wrong position.
The X position is related to the stem: stem up - zero is left of the note head, stem down - zero is at stem. Every drawing object has a zero position and is placed accordingly. The note heads are set by capella according to the rules and is not shown to the python interface. If you want to overcome this, you need to analyze the chord in the same way as capella does and add the head width to the X position.
Thanks for your response. Your discussion about the X position zero is helpful. I am placing note names in the heads, and even though I am applying a small X offset, I have noticed some are not perfectly centered.
Regarding the second interval offset note heads, I was expecting I might have to analyze the chord, but wondering if I would have to. Detecting collisions is not a problem, but detecting stem direction seems more of a challenge. I see that you have developed a considerable amount of logic for that in your Shaped_Notes.py script that I will study more in depth. Thanks for publishing that. I will also look more into the different head types you have proposed.