0
$\begingroup$

How can I find the name of an object given certain coordinates? What if there was more than one object with its origin at that point?

Thank you and I apologize for any errors: translated with PC!

$\endgroup$
2
$\begingroup$

All objects with origin within a tolerance of cursor.

Simple script to make a list of all objects whose origin is within a tolerance TOL of the scene.cursor_location.

import bpy

from bpy import context
scene = context.scene

TOL = 0.1 # get all objects within 0.1 bu of loc
#use cursor for location
loc = scene.cursor_location

obs_in_location = [o for o in scene.objects
        if (o.matrix_world.translation - loc).length < TOL]

print(len(obs_in_location), " at ", loc)
if len(obs_in_location):
    for o in obs_in_location:
        print("\t", o.name)
| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you, but I don't want to use the mouse position: I have a series of coordinates (x, y, z) and I would like to know from script if in a given position there is an object and if there is its name. $\endgroup$ – Ave Jan 17 '18 at 14:54
  • $\begingroup$ It's not the mouse position it's the 3D cursor. Edit such that loc = (x, y, z) then. The 3D cursor position was only being used as a basic example. There are no coordinates in question. $\endgroup$ – batFINGER Jan 17 '18 at 14:57
  • $\begingroup$ !!! sorry! Grazie. $\endgroup$ – Ave Jan 17 '18 at 15:00

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.