# Moving nodes with BCP macro help

I’m trying to write a simple macro to shift nodes from certain coordinates. After reading the scripting tutorials my understanding of Python in general and Glyphs macros specifically is still very limited, so I need some help with this. I figured out how to move the nodes I need, but it only moves the nodes themselves, the handles stay where they were. I circumvent this by declaring the handles for a second loop, but I’m sure there is a more elegant solution. This is my code so far:

``````for thisLayer in mylayers:
for thisPath in thisLayer.paths:
for thisNode in thisPath.nodes:
if(thisNode.y)==512:
thisNode.y = (thisNode.y + 10)

for thisLayer in mylayers:
for thisPath in thisLayer.paths:
for thisNode in thisPath.nodes:
if(thisNode.y)==546:
thisNode.y = + (thisNode.y + 10)
``````

There is no simple way to do this. Each node is on its own.

``````def moveNodes(layers, position, shift):
for thisLayer in layers:
for thisPath in thisLayer.paths:
nodeIndex = 0
for thisNode in thisPath.nodes:
if thisNode.type != OFFCURVE and thisNode.y == position:
thisNode.y = thisNode.y + shift
if thisNode.type == CURVE:
prevNode = thisPath.nodes[nodeIndex - 1]
prevNode.y = prevNode.y + shift

nextNode = thisPath.nodes[nodeIndex + 1]
if nextNode.type == OFFCURVE:
nextNode.y = nextNode.y + shift

nodeIndex += 1
moveNodes([Layer], 637, 10)

``````

Oh wow, thanks a lot! Works exactly as I needed it 