1
$\begingroup$

I've imported groups of object files (OBJs) into a Blender project and the problem is that they're all sitting on the 3D cursor one inside the other, so I'm looking for a quick way to evenly spread them out/distribute them. I can do this manually, but that's time-consuming. Any suggestions?

I found a YouTube video that recommends a built-in Blender Addon called Oscurart Tools. Unfortunately, Oscurart Tools are no longer included in Blender 3.0. I found a link to the tools (https://github.com/oscurart/Blender-28-Addons) and while I was able to installed them, I can't find any way to access them from any Blender menu. Again, anybody have any ideas? Thanks! Blender 3.0, Windows 11

$\endgroup$
3
  • 1
    $\begingroup$ I was having the same problem, the creator of Oscurart Tools created version 3.0 (github.com/oscurart/Blender-30-Addons) and it worked for me. $\endgroup$
    – user146188
    Apr 8, 2022 at 23:06
  • $\begingroup$ Thanks for the tip. I installed the tools, but unfortunately when I try to use Distribute Object, I get the message: "Needs at least two selected objects." I have multiple objects selected, but Oscurart seems to think I have only one selected. :( $\endgroup$
    – WilburPost
    Apr 9, 2022 at 23:10
  • $\begingroup$ If your question was solved, please be so kind and mark the answer that contributed to the solution as "Accepted Answer". This will make it easier for others to see which way leads to the solution, and the question will no longer appear as unsolved. Thank you! Here you can find more information: What should I do when someone answers my question?. If you still didn't get a solution to your question, please be kind enough to address it. $\endgroup$
    – quellenform
    Aug 21, 2022 at 23:24

3 Answers 3

3
$\begingroup$

You can solve this with a simple and short piece of code (python).

  1. Put all objects into one collection
  2. Open the Text Editor in Blender (SHIFT + F11)
  3. Enter the code below and fill in the name of the Collection and a value for the distance
  4. Run the script (click on the play button)
import bpy

# Starting offset
offset = 0
# Distance between the objects
distance = 3
# Name of the collection containing the objects
collection = "Objects"

for obj in bpy.data.collections[collection].all_objects:
    offset = offset + distance
    obj.location.x = offset
$\endgroup$
1
$\begingroup$

Here's a script that works on whatever is selected, and distributes the object's locations equally between the two extremes; you just have to type the axis name at the top of the script. Follow the directions in @quellenform's answer for how to run it.

AXIS = "y"

import bpy
selected = bpy.context.selected_objects
min_v = min([getattr(obj.location, AXIS) for obj in selected])
max_v = max([getattr(obj.location, AXIS) for obj in selected])
selected.sort(key=lambda obj: getattr(obj.location, AXIS))
offset = (max_v - min_v) / (len(selected) - 1)
for i, obj in enumerate(selected):
    setattr(obj.location, AXIS, min_v + i * offset)
$\endgroup$
0
$\begingroup$

When you import Kenny game assets into Bender they are all on 0,0,0, so I needed a way to spread them out over a grid.

So after import, I selected all, cleared the parenting (AltP/clear parent) and executed this script:

import bpy
selected = bpy.context.selected_objects

d = 20

x = 0
y = 0

xoffset = -d/2
yoffset = -d/2

offset = 2

for i, obj in enumerate(selected):
    obj.location.x = xoffset
    obj.location.y = yoffset
    
    yoffset += offset
    
    if i % 20 == 0:
        yoffset = -d/2
        xoffset += offset

result: enter image description here

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .