# How to get x,y,z location from a list with python?

How to get location from a list with python?

list = ["Cube1","Cube2", "Cube3"]

How can I get the Y location for the list?

I can get it for each individual object:

C1= bpy.data.objects["Cube1"].location


But I don't know how to convert list to [(X,Y,Z),(X,Y,Z),(X,Y,Z)]

• loclist = [bpy.data.objects[name].location[:] for name in namelist]? Or .location.y for the Y's? But maybe is this a Python question, not a Blender question? – Robin Betts Jul 4 at 22:52

Assuming we have the default cube and three clones as our object names, we can build new lists for the locations, and the Y locations. You asked for both in the question and I was unsure which you actually wanted...

import bpy

list = ["Cube","Cube.001", "Cube.002", "Cube.003"]
locations = []
yLocs = []

for n in list:
locations.append( bpy.data.objects[n].location )
yLocs.append( bpy.data.objects[n].location.y )

print( locations )
print( yLocs )