Last active
April 26, 2016 10:29
-
-
Save weiweihuanghuang/c28ca190c71ba6b9a56d20ede0b448a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#MenuTitle: Guideline through Selected Nodes | |
# -*- coding: utf-8 -*- | |
__doc__=""" | |
Creates a guideline through the currently selected two nodes. | |
""" | |
import GlyphsApp | |
import math | |
Font = Glyphs.font | |
selectedLayer = Font.selectedLayers[0] | |
try: | |
# until v2.1: | |
selection = selectedLayer.selection() | |
except: | |
# since v2.2: | |
selection = selectedLayer.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 | |
else: | |
myGuideline.angle = 90 | |
selectedLayer.addGuideLine_( myGuideline ) | |
selectedLayer.setSelection_(NSMutableArray.arrayWithObject_(myGuideline)) |
@mekkablue Whao that's weird...since the script used to work even like this. What should the indentation be?
Just tried it now with this new revision and it crashes right away,
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
closing parenthesis missing in L36
wrong indentation from L30 to the end