This:
anchors = []
for a in l.anchors:
if a.name == "bottom":
dupe = a.copy()
dupe.name = "cedilla"
dupe.selected = True # anchor not in the glyph yet, causes error
anchors.append(dupe)
anchors.append(a)
l.anchors = anchors
Will fail with:
Traceback (most recent call last):
File “”, line 26
File “GlyphsApp/GlyphsApp/init.py”, line 5972, in
File “GlyphsApp/GlyphsApp/init.py”, line 3855, in SetObjectInLayer_selected
AttributeError: ‘NoneType’ object has no attribute ‘selection’
One can remove the dupe.selected = True and do a second loop, after the anchors have been added, e.g.
for a in l.anchors:
if a.name == "cedilla":
a.selected = True
And this works. But is there a better way to write this? Specifically setting .selected on something that’s not yet in the glyph?