Is there a small script that allows you to space meshes apart equally?

Not space apart base on their pivot point as that would be useless if the meshes are of different sizes, rather space apart based on their outer most bounding boxes [AABB Boundary Test] so that the spaces between them are the same ?

did you try the array modifier ?

happy bl

Untitled-1
It behave like these two icons in Flash’s align tool.

can you elaborate
what is this image ?
is it done in blender or other soft ?

is this a 3D model in blender ?

happy bl

yes I can elaborate :smiley:
Untitled-1

These are Flat images because it is Flash [2D drawing program], I wish there is something like this in Blender ;p Is there ?

There used to be a Distribute tool in the Oscurart Tools add-on (should be bundled with Blender). I don’t recall whether it had spacing setting, nor can I say how well it works with 2.8x.

It’s something that could be written, albeit with a few caveats, e.g. Blender doesn’t store the order of selection for objects, so it may switch the objects around. Here’s a very simple script that spaces selected object on the X axis with a gap, ordering them by decreasing bounding box size:

import bpy
from mathutils import Vector

def get_object_size(obj):
    bb = obj.bound_box
    v0, v1 = Vector(bb[0]), Vector(bb[6])
    mtx = obj.matrix_world
    v0 = v0 @ mtx
    v1 = v1 @ mtx
    return (v1 - v0).length

def distribute_with_spacing(objects, gap):
    if len(objects) < 2:
        return
    dims = list(o.dimensions for o in objects)
    last_loc = Vector((0,0,0))
    objects[0].location = last_loc
    for i in range(1, len(objects)):
        da = dims[i-1]
        db = dims[i]
        offset = (da.x + db.x) * 0.5 + gap
        new_loc = last_loc + Vector((offset, 0, 0))
        objects[i].location, last_loc = new_loc, new_loc

#objects = bpy.context.selected_objects
#objects = sorted(bpy.context.selected_objects, key=lambda o: o.name)        
objects = sorted(bpy.context.selected_objects, key=get_object_size, reverse=True)

distribute_with_spacing(objects, 1.0)

are all your object the same shape - identical
also in line like the rectangles shown?

I mean this can be done with simple array in blender

happy bl

Ricky, how come you never read the original post? :laughing:

1 Like

you did not read all the posts too !

first post is
if the meshes are of different sizes,
but other one shows boxes all same size !

so hard to tell what the goal is here !

happy bl