schriftgestalt / GlyphsSDK

Scripting SDK for Glyphs
Apache License 2.0
89 stars 37 forks source link

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

Open Mark2Mark opened 2 years ago

Mark2Mark commented 2 years ago

>>> 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?

schriftgestalt commented 2 years ago
del(Layer.shapes[0])
Mark2Mark commented 2 years ago

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.

florianpircher commented 2 years ago

You can use shapeType.

Mark2Mark commented 2 years ago

Thanks!

Should anyone add that to the Documentation?

florianpircher commented 2 years ago

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

Mark2Mark commented 2 years ago

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)
florianpircher commented 2 years ago

Yes, that part is wrong.

Mark2Mark commented 2 years ago

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.

schriftgestalt commented 2 years ago

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 commented 2 years ago

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