Created
July 27, 2019 21:17
-
-
Save mekkablue/f05b582693916f61648e9d4a02623534 to your computer and use it in GitHub Desktop.
Select next/previous on-curve
This file contains hidden or 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: Select following on-curve point | |
# -*- coding: utf-8 -*- | |
__doc__=""" | |
From the currently selected point, go to the next on-curve. | |
""" | |
def getTheFirstPoint(selection): | |
for thisItem in selection: | |
if type(thisItem) == GSNode: | |
return thisItem | |
return None | |
def nextOnCurve(currPoint): | |
nextPoint = currPoint.nextNode | |
if nextPoint.type != "offcurve": | |
return nextPoint | |
else: | |
return nextOnCurve(nextPoint) | |
def prevOnCurve(currPoint): | |
prevPoint = currPoint.prevNode | |
if prevPoint.type != "offcurve": | |
return prevPoint | |
else: | |
return prevOnCurve(prevPoint) | |
def main(): | |
currentLayer = Glyphs.font.selectedLayers[0] # active layers of selected glyphs | |
selection = currentLayer.selection # node selection in edit mode | |
currentPoint = getTheFirstPoint(selection) | |
if currentPoint: | |
nextOnCurveNode = nextOnCurve(currentPoint) | |
currentLayer.selection = (nextOnCurveNode,) | |
if __name__ == "__main__": | |
# execute only if run as a script | |
main() | |
This file contains hidden or 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: Select previous on-curve point | |
# -*- coding: utf-8 -*- | |
__doc__=""" | |
From the currently selected point, go to the previous on-curve. | |
""" | |
import selectNodeNext | |
def main(): | |
currentLayer = Glyphs.font.selectedLayers[0] # active layers of selected glyphs | |
selection = currentLayer.selection # node selection in edit mode | |
currentPoint = getTheFirstPoint(selection) | |
if currentPoint: | |
prevOnCurveNode = prevOnCurve(currentPoint) | |
currentLayer.selection = (prevOnCurveNode,) | |
if __name__ == "__main__": | |
# execute only if run as a script | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment