# How do I move a vertex along the normal axis via scripting?

So I'm looking at using a python script to randomly move each vertex in a mesh back or forwards on the z axis.

I've got it moving on the local/global axis but I'm wondering how I can do this on the normal axis. I've tried doing the following:

for v in bm.verts:
v.co.z += v.normal.z * random.uniform(-0.05,0.05)


But this also only seems to move the vertices up and down, not outward like they would do if moving along the normal axis manually.

Anyway I'm probably missing something pretty simple here so thanks in advance.

## 1 Answer

if you only change v.co.z all will follow the z axis...

Try :

for v in bm.verts:
r = random.uniform(-0.05,0.05)
v.co.x += v.normal.x * r
v.co.y += v.normal.y * r
v.co.z += v.normal.z * r


As batFINGER says in the comment, that can be written as :

for v in bm.verts:
r = random.uniform(-0.05,0.05)
v.co += r * v.normal

• Thanks very much for the quick reply, it worked perfectly. – Luke Parker Jul 5 '16 at 13:55
• v.co += r * v.normal – batFINGER Jul 5 '16 at 14:00
• thanks @batFINGER... I don't really know Python... – lemon Jul 5 '16 at 14:01