Notifications
Clear all

[Closed] Search Objects by Radius/Distance from an object

Hey guys,

Is there a way to search objects in the scene by a specific radius (distance) from the pivot of an object?

Here is an example:

Thanks
Nahuel

2 Replies

You mean you want to collect all objects that are within a certain radius?
Or you want to get the distance to a specific object?

In the former case, you would say

theRadius = 500.0 --this is the radius to search within
 theObject = pickobject() --let the user pick a reference object by clicking in the viewport
 select (for o in objects where o != theObject and distance o theObject < theRadius collect o)
 

In the latter case, you can just use the (distance objectA objectB) expression to get the distance between any two objects. Note that distance() works on scene objects AND Point3 values, so you can also say (distance objectA.pos objectB.pos), as well as (distance objectA.pivot objectB.pivot), or even (distance objectA.pos [100,200,-300]) if you know a reference position in world space and want to specify it explicitly…

Yes, I wanted to collect all objects that were within a certain radius.
Thank you very much!