# Getting vertex coords of copied object [duplicate]

I have an object "box_template" that I want to create copies of and then get the position of its vertices withing the camera frame from.

So to create the copy I use:

new_box = box_template.copy()
new_box.data = box_template.data.copy()
new_box.animation_data_clear()


Then I move the copy using:

new_box.location = new_box_coords


So far this works as expected, the copies appear where I want them to be and render where they should.

Then I'm trying to get the position of the vertices within the camera frame using:

verts = (new_box.matrix_world @ vert.co for vert in new_box.data.vertices)
coords_2d = [bpy_extras.object_utils.world_to_camera_view(scene, camera_obj, coord) for coord in verts]

x_vals = [coord[0] for coord in coords_2d]
y_vals = [coord[1] for coord in coords_2d]
z_vals = [coord[2] for coord in coords_2d]

x_min = min(x_vals)

print("x_min: {}".format(x_min))


I expect this to print the x-coordinate of the left-most vertex of my freshly created copy.

Instead it prints it as if I never moved the copy from where the box_template object is (which is a negative value, because the original object is out-of-frame to the left)

I also tried using the template objects vertices instead to confirm that it prints the same value.

To me it seems as if world_to_camera_view() does not take the translation into account that I applied to the copy through its .location property.

Edit: I just checked, the vertices coordinates themselves are already wrong, it's not due to world_to_camera_view().

What am I missing? I thought new_box.matrix_world @ vert.co would apply all translations etc. to the coordinates?