GlyphsFilterRoundCorner vs removeOverlap

Hello, I am new to scripting and I am trying to understand some stuff I’ve stumbled upon. I don’t understand why the following code depends on if the removeOverlap line is before or after the selection of the node and it’s rounding. The following code successfully rounds the (250, 250) corner :

Font = Glyphs.font
thisLayer = Font.selectedLayers[0]
path = Layer.shapes[0]

for thisNode in path.nodes:
    #we know that a single node.x == 250
    if thisNode.x == 250:
        nodesToSelect.append((thisNode))

thisLayer.selection = nodesToSelect

GlyphsFilterRoundCorner.roundLayer_radius_checkSelection_visualCorrect_grid_(
	thisLayer, corner_radius, True, True, 1.0
)

thisLayer.removeOverlap() 

While this code fails to do so :

Font = Glyphs.font
thisLayer = Font.selectedLayers[0]
path = Layer.shapes[0]

thisLayer.removeOverlap()

for thisNode in path.nodes:
    #we know that a single node.x == 250
    if thisNode.x == 250:
	     	nodesToSelect.append((thisNode))

thisLayer.selection = nodesToSelect

GlyphsFilterRoundCorner.roundLayer_radius_checkSelection_visualCorrect_grid_(
	thisLayer, corner_radius, True, True, 1.0
)

If someone could explain this to me, it would help a lot ! :slight_smile:
edit : indentation doesn’t seem to work, sorry

For the indentation, add a blank line with three backticks (so ```) before and after each of your code blocks to format it as code, then the indentation will work.

I assume it is because you are changing the Layer.shapes array when calling the removeOverlap() function. When removing overlap, all paths are merged as far as possible, potentially changing the list of paths (possible re-building it no matter whether a different result is achieved through overlap removal or not).

Also, just a note on your formatting: you’re missing an indented block in your second snippet, in the first for loop.

Indeed if I redefine

path = Layer.shapes[0]

after removing overlaps, it works.

yet the path seems identical…

Thank you for your answer !