Scripting in macro

I got this error when try the code from a tutorial:

https://glyphsapp.com/tutorials/scripting-glyphs-part-3

#MenuTitle: Glyph Shaker
# -*- coding: utf-8 -*-
__doc__="""
Goes through all selected glyphs and slaps each of their nodes around a bit.
"""
import random
random.seed()
for thisLayer in selectedLayers:
    for thisPath in thisLayer.paths:
        for thisNode in thisPath.nodes:
            thisNode.x += random.randint( -50, 50 )

output

 Traceback (most recent call last):
      File "<string>", line 8, in <module>
    NameError: name 'selectedLayers' is not defined

you are missing this line:

selectedLayers = Glyphs.font.selectedLayers
1 Like