Macro: How to turn a single node into two nodes with handles in between them, all on top of each other

Hello Glyphs people who know more than I do!

I am wondering if anyone could help me with some python for the macro window. I am trying to turn a single node into two nodes with handles in between them, all on top of each other. I am sure there is a way, but I am quite new to using the macro window so I am missing it.

Any help appreciated!

Try this:
for path in Layer.paths:
	for index, node in enumerate(path.nodes):
		if node.selected and node.type!=OFFCURVE:
			for nodeType in (OFFCURVE, OFFCURVE, CURVE):
				newNode = GSNode()
				newNode.position = node.position
				newNode.type = nodeType
				path.nodes.insert(index, newNode)

Here is an improved version (the one above would not work with corner nodes:

for path in Layer.paths:
	nodeindexes = reversed(range(len(path.nodes)))
	for index in nodeindexes:
		node = path.nodes[index]
		if node.selected and node.type!=OFFCURVE:
			for nodeType in (CURVE, OFFCURVE, OFFCURVE):
				newNode = GSNode()
				newNode.position = node.position
				newNode.type = nodeType
				path.nodes.insert(index+1, newNode)
1 Like

Fantastic! Thanks for this Rainer. Hopefully one day I will be able to figure this out for myself :slight_smile: