2

I have created a cube in blender and I have resized it. When I use the following code to print the coordinates, it prints the coordinates for the original cube (not the resized one). Could you let me know how I can get the coordinates for the resized cube?

for item in bpy.data.objects:        
    print(item.name)  
    if item.type == 'MESH':  
        for vertex in item.data.vertices:  
            print(vertex.co)  
Farhad
  • 163
  • 10

1 Answers1

1

As others have mentioned, you need to apply the scale transform you performed. I would do something like:

bpy.ops.object.select_all(action='DESELECT') # deselect everything to avoid a mess
for item in bpy.data.objects:
    print(item.name)
    if item.type == 'MESH':
        item.select = True # lets select every mesh as we go
        bpy.ops.object.transform_apply(scale=True) # apply transform
        item.select = False # we're done working on this object
        for vertex in item.data.vertices:  
            print(vertex.co)