Copy the hints on a path while copying from the path In script or plug-in?

What is a good way to copy the hints (such as corner parts) on a path while copying it from the path?
I mean the hints in the current layer applied to a path.

You are trying to copy the path including the corners to a different glyphs?

Does this help?

sourceLayer = Font.glyphs["A"].layers[0]
targetLayer = Font.glyphs["B"].layers[0]

path = sourceLayer.shapes[0]

pathDict = GSLayer.pathDict_corners_(path, list(sourceLayer.hints))
transfere = {
	"shapes": [pathDict]

print(targetLayer.pasteDict_selectedNodes_error_(transfere, None, None))

Thank you for your method, which is effective for corner components added through normal nodes.
If a corner component is added through additional nodes, which method above cannot obtain corner component information? If so, how to handle this situation?

The above additional nodes refer to the nodes displayed by checking the options in the above image. Corner components added through this node cannot be obtained through the following methods

GSLayer.pathDict_corners_(path, list(sourceLayer.hints))

There is no build in way (at least not one accessible from a script) to copy those corners.

Trying this, I realized that when manually copy pasting to a glyph that already has outlines, the corner will not be attached correctly.

Sorry, I don’t quite understand the meaning of the above paragraph.

Or in another way,is there a method equivalent to command+C and command+V,After selecting a path, execute command+C and command+V can synchronously copy such additional corner components.
I found that,through command+C, a selected path can be obtained a dict for NSStringPboardType of ‘Glyphs elements pasteboard type v3’.

Maybe this helps:

from Foundation import NSPropertyListSerialization
sourceLayer = Font.glyphs["C"].layers[0]
targetLayer = Font.glyphs["D"].layers[0]

selectedObjects = sourceLayer.selectedObjects()
glyphsDataCurrent = GSLayer.layerDataFromDict_format_error_(selectedObjects, GSFormatVersionCurrent, None)

dictionary, _, _ = NSPropertyListSerialization.propertyListWithData_options_format_error_(glyphsDataCurrent, 0, None, None)
targetLayer.pasteDict_selectedNodes_error_(dictionary, None, None)

Thanks George,I will try it soon.

Hello Georg, I used the method mentioned above yesterday. I am in version Glyphs3.2, that is OK,

NSData *glyphsDataCurrent = [GSLayer layerDataFromDict:Layer.selectedObjects format:GSFormatVersionCurrent error:nil];

but earlier versions 3.0 and 3.1 will report errors. Does this method not exist in earlier versions?Or is there another reason?

+[GSLayer layerDataFromDict;format:error:]: unrecognized selector sentto class 0x10fb78090

In earlier versions, it is without the error argument:

NSData *glyphsDataCurrent = [GSLayer layerDataFromDict:Layer.selectedObjects format:GSFormatVersionCurrent];