Move selected glyphs

Hello, I need to do a little script that move all my selected glyphs to posY -11. Tried:

myLayers = Glyphs.font.selectedLayers
for thisLayer in myLayers:
	thisLayer.y = -11

and I got this error.

Traceback (most recent call last):
File “”, line 3, in
AttributeError: ‘GSLayer’ object has no attribute ‘y’

I did it with nodes, but it moves each node, but not the whole shape…

The layer doesn’t have sizing properties like nodes. The only thing it has are the ‘bounds’. Use this to calculate the needed offset and use the applyTransform method:

bounds = Layer.bounds
minY = bounds.origin.y
offsetY = -11 - minY
Layer.applyTransform([1, 0, 0, 1, 0, offsetY])
1 Like

Perfect, works great. Thanks

Why this is not working for all selected glyphs? It only works on the one is focused:

myLayers = Glyphs.font.selectedLayers
bounds = Layer.bounds
minY = bounds.origin.y
offsetY = -11 - minY
for thisLayer in myLayers:
	thisLayer.applyTransform([1, 0, 0, 1, 0, offsetY])
	print "Applied to:" + " " + thisLayer.parent.name

You need to put the second and third line inside the loop and get the bounds from ‘thisLayer’

1 Like