Question about copying paths via scripts

As in my Topic, I have a question about copying paths:

I tried to copy paths from layer to another in two ways:

import copy
layer.paths = copy.copy(anotherlayer.paths)

As I experienced, the first option is safer
(after using the second option I ended up with
strange paths without nodes like in the picture below).

But with first option I didn’t figured out how to copy paths to the layer without deleting ones already existing. With second that’s easy.
Is there easy way to achieve that? (without strange “nodeless paths”?)
I’m stuck.
thanks for your help in advance

I figured out when option Nr 2 ends with mentioned result (nodeless paths):
this outline reveals in layer, from which I copied paths. It reveals when I’m deleting copied path in second layer.
I guess before I use layer.paths.append(anotherlayer.paths) I should create a new, separate object GSPath() which will be appended to layer.paths.

1 Like

Try layer.paths.append(copy.copy(otherLayer.paths))

Or copy the layer object with its very own copy() method:

otherLayer = Font.glyphs["X"].layers[0]
otherPaths = otherLayer.copy().paths

I managed to do it by creating new GSPath().
After this I imputed segments from origin-path to my brand new GSPath, and then:


and voilà!
In the end I had to make sure that new path is properly closed and that smooth points from origin-path stay smooth in new path