I know about divideCurve() but I’m wondering if there’s already a function (insertNodeWithPathTime_ maybe? ) to split a line instead of having to write the script that will delete and write a new one like here:
thisLayer = Glyphs.font.selectedLayers[0]
pathList = []
for n in thisLayer.paths[0].nodes:
pathList += [(n.x, n.y)]
print n
newPathList = divideCurve(pathList[0],pathList[1],pathList[2],pathList[3],0.5)
print newPathList
thisLayer.paths = []
newPath = GSPath()
for i, p in enumerate(newPathList):
# print i, p
if i in [1,2,4,5]:
pPoint = GSNode(p, "offcurve")
newPath.addNode_(pPoint)
elif i in [3,6]:
pPoint = GSNode(p, "curve")
pPoint.smooth = 1
newPath.addNode_(pPoint)
elif type(p) != 'NSPoint':
pPoint = GSNode(p, "line")
newPath.addNode_(pPoint)
thisLayer.addPath_(newPath)
What do you try to do? If you just like to divide an existing path, insertNodeWithPathTime_ is all you need. The calculation of the proper path time value is a bit tricky. You need to use the index of the node that is at end of the segment in question and add the t value you need.