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.


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
  • $\begingroup$ Thanks very much for the quick reply, it worked perfectly. $\endgroup$ – Luke Parker Jul 5 '16 at 13:55
  • 2
    $\begingroup$ v.co += r * v.normal $\endgroup$ – batFINGER Jul 5 '16 at 14:00
  • $\begingroup$ thanks @batFINGER... I don't really know Python... $\endgroup$ – lemon Jul 5 '16 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.