Guideline through selected nodes script not working

I know, the script doing this has been abandoned, because the feature has been implemented into the context menu. The script stopped working with the latest version (811).

@mekkablue could you still please fix it? I heavily prefer to have shortcuts for everything and because context menu operations can not be shortcuted (to my knowledge), the script was always very useful to me. Also the center guideline script, btw.

Guideline through selected nodes script:

import GlyphsApp
import math

Font = Glyphs.font
thisLayer = Font.selectedLayers[0]
selection = thisLayer.selection()

if len( selection ) == 2:
firstPoint = selection[0]
secondPoint = selection[1]
xDiff = firstPoint.x - secondPoint.x

myGuideline = GSGuideLine()
myGuideline.position = NSPoint( firstPoint.x, firstPoint.y )

if xDiff != 0.0:
	tangens = (firstPoint.y - secondPoint.y) / xDiff
	myGuideline.angle = math.atan( tangens ) * 180.0 / math.pi
	myGuideline.angle = 90

thisLayer.addGuideLine_( myGuideline )

You need to remove the parentheses at the end of line 12, so that it looks like:

selection = thisLayer.selection
1 Like