Trying to write a script that adds guides for each selected node/anchor separately. Just started learning python. So far I could manage adding as many guides to the baseline as the number of nodes in the selected glyph
font = Glyphs.font
selectedLayer = font.selectedLayers[0]
for node in path.nodes: # (or path.anchors etc.))
guideLine = GSGuide()
print (guideLine)
guideLine.position = NSPoint(0, 0)
guideLine.angle = 0
selectedLayer.guides.append(guideLine)
You haven’t defined path; the code may work because it takes previously used variable from cache (?), but you’ll get weird results and spend days finding the problem
You can iterate over selected nodes with Layer.selection, no need to go through every point.
To change guide’s position just take the position from the node position. Probably separate x and y? Check if a guide at that x/y already exists?
font = Glyphs.font
selectedLayer = font.selectedLayers[0]
for node in selectedLayer.selection:
guideLine = GSGuide()
guideLine.position = node.position
guideLine.angle = 0
selectedLayer.guides.append(guideLine)