How to arbitrarily add a point to a Bezier curve through a python script

Hello, how do you add any point to a Bezier curve through a python script? Thank you very much

You mean to an outline in a glyph?

this will simply add a node. You need to make sure that it isn’t in between some curve nodes.

path.nodes.insert(3, GSNode((10, 100)))

If you like to add a node similar how you the pen tool does it when you click the outline:

path = Layer.shapes[0]
point = (100, 100)
actualPoint, pathTime = path.nearestPointOnPath_pathTime_(point, None)
1 Like

Thank you very much for your answer!!!

How to resolve this error: ‘NSKVONotifying_GSLayer’ object has no attribute ‘shapes’

What version of Glyphs do you have? I suspect that you have Glyphs 2. In this case, you need to replace shape with paths.

Thanks very much!!