Notifications
Clear all

[Closed] align A to center of B

how to align box to my objName(object). I need to preserve rotation and position – I have to align object A exactly on center of Object B.

4 Replies

If you have not reseted the transform matrix of the objects, this should work:

$ObjectA.center = $ObjectB.center

it’s fine but my programming skill is very low:(

in my code one obejct is variable. It should look like this:

objNamee = selection[1].name
$Torus001.center = objNamee.center

but won’t work. What I do wrong?

1 Reply
(@polytools3d)
Joined: 11 months ago

Posts: 0

As Kostadin said, you are accessing the name property of the object rather than the object itself.
So in your code it tries to align an object with a string (the name of the other object).
Try one of these:

objA = selection[1]
 $Torus001.center = objA.center

or

$Torus001.center = selection[1].center

objNamee = selection[1]
 $Torus001.center = objNamee.center

selection[1].name will gives you the name of the selected object, not the object.