1

I want to make multiple copies of a complex mesh and space them apart so that they barely touch. What I have now is a script like this:

import bpy

C = bpy.context src_obj = bpy.context.active_object x_size = src_obj.dimensions.x

for i in range (1,5): new_obj = src_obj.copy() new_obj.data = src_obj.data.copy() new_obj.animation_data_clear() new_obj.location.x += i * x_size C.collection.objects.link(new_obj)

However, if I rotate the original object around the z axis, x_size doesn't really refer to the x dimensions in world space anymore, so the spacing between the objects is off. How do I get the dimensions along the world space instead?

dan
  • 111
  • 2
  • You can use bound box of object ob.bound_box. Find min and max values of X in 8 vectors of bounding box. max - min will give you desired result. https://blender.stackexchange.com/a/8470/115433 – Reigen Sep 14 '21 at 05:59
  • I tried doing it like in the link, but that gives me the distance between diagonal points, that's not the size along the world x-axis, but something bigger. What I want is to get a bounding box where one side is oriented along the x axis. – dan Sep 14 '21 at 08:11
  • 3
    @dan link gives the bbox in global coordinates but (shapewise is still) axis aligned to the local coords of the object. See https://blender.stackexchange.com/questions/223858/how-do-i-get-the-bounding-box-of-all-objects-in-a-scene – batFINGER Sep 14 '21 at 09:33
  • @batFINGER I know, that's why I said it doesn't really apply to my problem. For now I just apply the rotation to the object before doing anything else, that sidesteps the problem. – dan Sep 15 '21 at 00:12

0 Answers0