How to use Python scripts to implement the reconnection point function in glyphs, or can Python be used to call it?

How to use Python scripts to implement the reconnection point function in glyphs, or can Python be used to call it?

Layer.reconnectNodesAtNode1_node2_offset_(nodesA, nodesB, distance)

where nodesA and nodesB should be the CURVE or LINE nodes of a path in Layer, and distance can be customized if you want more offset space after reconnection.

for example:

thisNodes = Layer.shapes[0]
Layer.reconnectNodesAtNode1_node2_offset_(thisNodes[2], thisNodes[13], 10)

Thank you, this is great!!!

But in glyphs2, an error is reported:
Traceback (most recent call last):
File “”, line 10, in
AttributeError: ‘NSKVONotifying_GSLayer’ object has no attribute ‘reconnectNodesAtNode1_node2_offset_’

There are other functions in glyphs2 that can replace reconnectNodesAtNode1_ node2_ offset_ Is it okay

Well, I have Glyphs 3 only that the API might be different from Glyphs 2.

However, you can list all properties and methods via

print( dir(Layer) ) 
# or
print( dir(Layer.shapes[0]) ) 

and try to find the related attributes by keyword such as reconnect and so on.

How to know the meaning of parameter input for attributes

I hope that the method names should give a good idea about the parameters.
Those methods with underscores are actually objectiveC selectors that where translated to python. The one mentioned above is defined like this:

- (void)reconnectNodesAtNode1:(GSNode *)node1 node2:(GSNode *)node2 offset:(CGFloat)offset;

For some methods you can check the headers files in: Glyphs 3.app/Contents/Frameworks/GlyphsCore.framework/Versions/A/Headers or in Glyphs Core API

Thanks very much!!!