2
$\begingroup$

I can print a vertex in Blender, but how do i do basic math operation; Like add multiply or divide them with other 3d coordinates ?

As here the last line doesnt work :

      for face in current_obj.data.polygons:
           verts_in_face = face.vertices[:]
           print("face index", face.index)
           print("normal", face.normal)
      for vert in verts_in_face:
           local_point = current_obj.data.vertices[vert].co
           total_points = total_points + local_point  # <<< error here
$\endgroup$
1
  • $\begingroup$ How are total_points and current_obj defined? And should the second for loop be indented further? $\endgroup$
    – user2699
    Jan 1 '15 at 19:40
1
$\begingroup$

When you initialize total_points outside the loop it should work

import mathutils
..
..
total_points = mathutils.Vector((0,0,0))

for vert in verts_in_face:
    local_point = current_obj.data.vertices[vert].co
    total_points = total_points + local_point

For all available vector operations you can lookup the mathutils docs

$\endgroup$
0

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.