GlyphsSDK icon indicating copy to clipboard operation
GlyphsSDK copied to clipboard

delete path with `del(Layer.paths[0])` not supported

Open Mark2Mark opened this issue 3 years ago • 10 comments

>>> TypeError: 'GSProxyShapes' object doesn't support item deletion

The documentation claims that it is possible like that.

Also: what’s the proper API now to delete/add paths?

Mark2Mark avatar Aug 22 '22 15:08 Mark2Mark

del(Layer.shapes[0])

schriftgestalt avatar Aug 22 '22 18:08 schriftgestalt

Thanks!

Is there an easy way to distinguish between paths and components? When a user wants to only delete either or. I know one could type check as on objc, but for the regular python user? It’s not all too clear with the .shapes I think.

  • [ ] The documentation needs an update then. del(layer.paths[0])del(Layer.shapes[0])

Mark2Mark avatar Aug 23 '22 11:08 Mark2Mark

You can use shapeType.

florianpircher avatar Aug 23 '22 13:08 florianpircher

Thanks!

Should anyone add that to the Documentation?

Mark2Mark avatar Aug 23 '22 15:08 Mark2Mark

I linked to the documentation. Or what other documentation do you use?

florianpircher avatar Aug 23 '22 16:08 florianpircher

Didn’t see that it is a link. I also linked mine, though (twice 😉 ) Tried to point y’all to the part under GSLayer > paths, where it says:

# access all paths
for path in layer.paths:
print(path)
# delete path
del(layer.paths[0]) # <------------- this is what I am talking about.
# copy paths from another layer
import copy
layer.paths = copy.copy(anotherlayer.paths)

Mark2Mark avatar Aug 23 '22 16:08 Mark2Mark

Yes, that part is wrong.

florianpircher avatar Aug 23 '22 16:08 florianpircher

I’d love to help with the docu, but I have no access or clue how it is generated. Hence I can only drop all my findings here.

Mark2Mark avatar Aug 23 '22 16:08 Mark2Mark

The docu is generated from the comments in the wrapper file. It uses a script to extract the comments and then uses sphinx to build the html. https://github.com/schriftgestalt/GlyphsSDK/tree/Glyphs3/ObjectWrapper/Sphinx%20Documentation

schriftgestalt avatar Aug 24 '22 14:08 schriftgestalt

The formatting is a bit tricky (indentation and empty lines). I can clean it up if needed.

schriftgestalt avatar Aug 24 '22 14:08 schriftgestalt