0
$\begingroup$

First I import a cone next to a box:

enter image description here

The cone has a good position in the X axis but not in the Y and Z axis.

So I translate it to this position :

enter image description here

Ideally, I want about 1 mm between the edges of the box and the center of the cone. I was wondering how can I translate the cone to that position (which is linked to the box) with a python script ?

$\endgroup$
4
  • $\begingroup$ is the origin of the box at its center ? $\endgroup$ – Chebhou Mar 23 '15 at 14:53
  • $\begingroup$ When I import the cone, both origins of the box and the cone are at the same position (0,0,0). $\endgroup$ – reflyon Mar 23 '15 at 15:01
  • $\begingroup$ i mean at their geometry center $\endgroup$ – Chebhou Mar 23 '15 at 15:02
  • $\begingroup$ No, they are not, but after playing a bit with your script I obtain what I want, thanks ! $\endgroup$ – reflyon Mar 23 '15 at 15:48
0
$\begingroup$

If both objects origins are at their centers ; set their names in the script and run it :

import bpy

cone = bpy.data.objects['Cone']
box = bpy.data.objects['Cube']

edge = box.dimensions[2]/2 + box.location[2]
cone.location[2] = edge-0.1  #assuming 1BU->1cm
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.