gaya
gaya

Reputation: 465

Get image/world co-ordinates of exact number of vertices only

I am trying to find transformation parameters between a mesh and and it's translated, rotated form by using a simple least square estimate. For this I need world co-ordinates of the mesh vertices which I have already.

But I do not need all the vertices just say a fixed number like 5 or 10. I do not want to select the vertices and get it's co-ordinates but just a simple python code like a loop which gives co-ordinates of say 10 vertices.

I am okay with blender but bad with programming in blender. Any help is appreciated!

I am using the following code to get world coordinates of the object.

import bpy
obj = bpy.data.objects['Coil_body18']
wm = obj.matrix_world

for v in obj.data.vertices:
    local = v.co
    world = wm * v.co
    print('vertice_world',world)

Upvotes: 1

Views: 80

Answers (1)

gaya
gaya

Reputation: 465

After some trials I figured out the answer myself. All I had to do was to specify the range in following way to get 20 vertices only.

import bpy
obj = bpy.data.objects['Coil_body18']
wm = obj.matrix_world

for v in obj.data.vertices[0:20]:
local = v.co
world = wm * v.co
print('vertice_world',world)

In general sense, to get n vertices in a loop,

for v in your_object.data.vertices[0:n]

Upvotes: 1

Related Questions