I’m starting to learn to script on Glyphs with this tutorial Scripting Glyphs, Part 2 | Glyphs
I have Glyphs 3 and Glyphs 2. But, it seems that accessing paths doesn’t work on Glyphs 3 but works in Glyphs 2. Could you explain me what could be the issue there? Thanks.
On Glyphs 3, I have this result:
On Glyphs 2, I have this result, which is right:
(<GSPath 40 nodes and 24 segments>)
Here is a screenshot of Glyphs 3 macro window:
In Glyphs 3, the
paths property of a layer can only be iterated but not modified. You can write a
for loop that iterates over the paths of layer like so:
for path in Layer.paths:
This iterates over the paths of the current layer.
To modify the paths of a layer (delete paths, insert new paths) in Glyphs 3, use the
shapes property on a layer which contains all paths and components on a layer. You can iterate over the shapes of a layer like so:
for shape in Layer.shapes:
if shape.shapeType == GSShapeTypePath:
print("a path:", shape)
elif shape.shapeType == GSShapeTypeComponent:
print("a component:", shape)
See the Python documentation for details: Glyphs.app Python Scripting API Documentation — Glyphs.app Python Scripting API 3.0 documentation
Thanks for your quick answer, I will look at this!
I’m also starting to learn to script on Glyphs with the same tutorial. Now i’m stuck on part 2 as the result is not updated yet. Can anyone please tell me how the code would look like to have the same results as in Glyphs 2?
I need to update those tutorials. I hope I get around to it next week.
@Nicolien can you be more specific: which code are you trying to run that produces no output? I assume you use Glyphs 3.
It is working now thanks to mekkablue and Georg. This is the code: