Hello, I am running into an issue with the GSLayer.connectPathsWithNode_andNode_() method. If the two nodes have the same position, one of them is deleted. I need to keep them both.
Is there another method of connecting nodes, which retains both nodes even if they share the same position? Thanks!
With segments, you mean GSPath objects?
In this case:
You start with:
two open paths:
check if the two connection nodes are in the right order. The first node needs to be the end node of its path and the second needs to be the start node. Either switch the paths or reverse one or both segments.
In case anybody else is looking for this, it’s actually very easy:
for index in range(len(Layer.paths) - 1):
for index, node in enumerate(Layer.paths[1].nodes):
proxy_layer.paths[0].nodes.append(node)
Layer.shapes.remove(Layer.paths[1])
Layer.paths[0].closed = True
This will iterate over all segments, which are separate paths in the layer, and copy the next path’s nodes to the first path, essentially just connecting them. It then removes the next path. In the end, the resulting single path is closed.