0
$\begingroup$

I am trying to get a list of all objects that have specific position. For example, get me all objects that have (x,y,z) < 1. How do I do this?

import bpy

objects = bpy.context.scene.objects

for obj in objects:
    
$\endgroup$

1 Answer 1

3
$\begingroup$
import bpy

objects = bpy.data.objects

lis = [obj for obj in objects if obj.location.x < 1 and obj.location.y < 1 and obj.location.z < 1]

# or
lis = []
for obj in objects:
    if obj.location.x < 1:
        if obj.location.y < 1:
            if obj.location.z < 1:
                lis.append(obj)
$\endgroup$
2
  • $\begingroup$ Hi thank you. I get a list here and is there a way to select all the objects that satisfies this condition? $\endgroup$
    – Vika
    Jul 13 at 9:37
  • $\begingroup$ for obj in lis: obj.select_set(True) $\endgroup$
    – X Y
    Jul 13 at 9:43

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.