Error in __init__.py

Hi, I have a script for clearing each layer content (both paths and components).
It works but the macro window displays this message:


Start
Traceback (most recent call last):
File “Clear_Icon.py”, line 27, in
for thisLayer in thisGlyph.layers:
File “GlyphsApp/init.py”, line 1792, in next
IndexError: NSRangeException - *** -[__NSArrayM objectAtIndexedSubscript:]: index 14 beyond bounds [0 … 13]
End


Thanks a lot.

Can you send me the script?

Sure, here it is:

#MenuTitle: Clear Icon
# -*- coding: utf-8 -*-
__doc__= """
Clear selected icon
"""
import time
import random
random.seed()

Glyphs.showMacroWindow()
Glyphs.clearLog()


Font = Glyphs.font
selectedLayers = Font.selectedLayers

Font.disableUpdateInterface()

for currentLayer in selectedLayers:
	thisGlyph = currentLayer.parent
	thisGlyph.beginUndo()
	
	for thisLayer in thisGlyph.layers:
		thisLayer.components = []
		thisLayer.paths = []
	thisGlyph.endUndo()

Font.enableUpdateInterface()

print (thisGlyph.name)
print time.strftime('%X %x %Z')
print ('\n')

sorry, I can’t find how to attach a file in the post.

The script runs fine for me. What version of Glyphs do you have?

2.4.4 (1075)

Do you want to test it with my file?

Can you try the latest version (2.5.1)?

I’m trying to update but I got this message:


Glyphs can’t be updated when it’s running from a read-only volume like a disk image or an optical drive. Move Glyphs to your Applications folder, relaunch it from there, and try again.


Glyphs is in my Application folder.

Anyway, never mind. The script works, even with the error message, no problem. It was just to know what was happening behind the scene.

Is the ‘Check for updates…’ the unique method to update?

You can download version 2.5 and try to update it then.

Ok, I’m going to try…

Well, Glyphs updated, ok.
Same error message but the script works fine.

Thanks for your quick support.

One more thing. I received the ‘change picture’ advice but I can’t find how to.

You got the advice from the forum?

And if still get the error message, you might send me the file.