The function append does not work in G3

The following script does not work right in G3, but it works right in G2.
I found the function append does not work sometimes, that’s why the xPaths is empty.
but , I don’t know where is wrong?


import copy
from Foundation import NSMakeRect, NSIntersectsRect

xPaths = []

pLayer = Glyphs.font.glyphs["space"].layers[0]
checkRect =  NSMakeRect(0, 350, 300, 300)
for p in aLayer.paths:
	if NSIntersectsRect(checkRect, p.bounds):
		xPaths.append(p.copy())
print(xPaths)

test.glyphs (6.8 KB)

Please help to find the reason.
Thanks.

Use layer.shapes instead of layer.paths: Glyphs.app Python Scripting API Documentation — Glyphs.app Python Scripting API 3.0 documentation

I think you script has a typo: you assign pLayer and then access aLayer. That might be available from another script.

Yes, the ‘aLayer’ should be ‘pLayer’.
and use shapes is correct now.:slight_smile:
Thanks a lot.