Clear all selected glyphs

I thought this was possible in the Font tab, by selecting all glyphs and then Edit > Clear, but this is currently disabled?

What version do you have?

1.4.1 (543)

If you want to delete selected glyphs, that’s command+delete. Is that what you want to do?

If you want to keep the glyphs, but just want to empty them out, use the Paths > Delete All Paths script from https://github.com/mekkablue/Glyphs-Scripts

And/or perhaps Components > Delete All Components from the same source.

There are situations when the Clear command would be very helpful. Sometimes you want to see the background sample glyphs, sometimes you want to simply start again and clear all masters of one letter (but you want to keep the glyph). Georg told me today he thinks about adding this feature to the app. I hope he’ll do it soon.

‘Clear’ hangs when I’m trying to clear 1200 glyphs, On Glyphs 657 / 10.9.5 (finally!)

It was just taking it's time. I improved it a bit.

I am trying to delete all paths in a layer (I want to keep anchors, glyphs name, advance width but not the paths). I am trying this lines but I have not had success in this task:

for layer in Glyphs.font.selectedLayers:
	
	####################
	#  Removing paths  #
	####################
	
	for i in range(len(layer.paths))[::-1]:
		del(layer.paths[i])

I am following as the Glyphs 2 API says, but Glyphs is warning me with this message:

Traceback (most recent call last):
  File "<string>", line 30, in <module>
  File "/Users/georg/Programmierung/Glyphs/Glyphs/Glyphs/Scripts/GlyphsApp.py", line 935, in __delitem__
UnboundLocalError: local variable 'Key' referenced before assignment

Is something wrong in what I am doing?

Also @mekkablue script is having the same message.

The easiest way may be to do this:

layer.paths = []

or this:

layer.removePath_( layer.paths[i])

Sweet :smiley: this works! Thanks @Tosche

did you try?

del(layer.paths[i])

That is the normal way to remove something from a list in Python

But to delete all paths use the first example from Tosche.

Thanks very much @GeorgSeifert I tried layer.removePath_( layer.paths[i]) and works perfectly.
Best,
NicolĂĄs

I really recommend to use the “pythonic” methods:

layer.paths = [] # to clear all path

of

del(layer.paths[i]) # to remove one individual path

I catch it now, this is a kind of reset the list of paths to zero.

I doubt if this post is relevant to the current Glyphs 2.0 since it has been threaded;
But I’m wondering why the “Delete/Clear” several selected glyphs still cause a crash??
V. 2.1.1 (771)

Which one are you talking about? The script or the menu entry Edit > Clear?

I Clear with the shortcut "Comm. Del."
Check the screen cast :

That is not clearing glyphs, but deleting glyphs. The crash in the screencast is fixed in the latest beta. You can switch to the beta version by activating Glyphs > Preferences > Updates > Show Cutting Edge Versions.

1 Like