Expand outline with a script only for unclosed paths

Hi. I have a glyph with a mixed paths types – an already closed paths that I don’t want to touch, and unclosed paths with a stroke width which I want to expand. The design is pretty complicated and there are a lot of paths, so It’s not easy to manually select an unclosed ones.

Here’s what I tried:

for path in Layer.paths:
	if not path.closed and path.attributes['strokeWidth']:
		path.flattenOutlines()

An error:

'GSPath' object has no attribute 'flattenOutlines'

I also tried path.expandStroke() and path.expandedStroke() that also follow to a similar errors. I will be grateful for any help.

Check the Method Reporter plugin from mekkablue, it will give you more clues as to which methods exist and which don’t.

GSLayer has the following:
flattenOutlines()

GSPath has these:
flattenendOutlines() (this has a typo, btw, it should be flattenedOutlines() @GeorgSeifert )
expandedStroke()

Maybe these methods yield what you are looking for.

I fixed that typo an hour ago.

Thanks Sebastian.
Unfortunately, neither flattenendOutlines() / flattenedOutlines() nor expandedStroke() works at the moment, although the last one does not cause an error in the Macro.

Currently I use the following script to select all an unclosed paths with a stroke width, and then expand it manually. I’m fine with that.

Layer.clearSelection()
Glyphs.font.disableUpdateInterface()

for shape in Layer.shapes:
	if not shape.closed and shape.attributes['strokeWidth']:
		for node in shape.nodes:
			Layer.selection.append(node)

Glyphs.font.enableUpdateInterface()

I needed to add some API to make this possible. Will be in the next update.

Thanx!