Scripting in macro

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

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


 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