I need to make an image in which there are two objects when one of them is located regularly on the plane but the second is actually a bit on top of the first one when they do not touch each other. It is actually not realistic because the second object is hung in the 'air' without any support. For example, in the attached image, the sphere is located (not realistically) on top of the cube. I tried to use the function of bpy.ops.transform.translate(value=(x, y, scale)), but none of its parameters controls the height of objects. Do you have an idea how can I make it?
1 Answer
Just a cheap solution:
import bpy
# need 'Cube' and 'Sphere'
cube = bpy.data.objects['Cube']
sphere = bpy.data.objects['Sphere']
for idx in range(3):
sphere.location[idx] = cube.location[idx] # loc x,y,z is same
sphere.location[2] += (cube.dimensions[2]/2) + (sphere.dimensions[2]/2) # move sphere to top of cube
-
$\begingroup$ Thank you very much! it is exactly what I needed. $\endgroup$– DaveNukDec 7, 2021 at 15:45