ScriptSpot

Forum topic · Scripts Wanted

Align selected object to object "A" (XYZ) and then to object "B" (Y)

By sampei · 2020-07-11

Description

Hello! basically I have a dummy object "X" and 2 geometry objects "A" and "B".

I need to align the selected Dummy "X" firstly to "A" on all of its axes, and then to "B" only on its Y axis.

I have found the following line which aligns the selected object to all axes XYZ (oddly it squashes the Dummy's bounding box)

$.transform = (getNodeByName "A").transform

$.transform = (getNodeByName "B").transform

and what I need is for the second line of code to constrain the transform operation to the Y axis.

The normal way of doing this is by using the ALIGN tool twice (first on A and then on B disabling X and Z), but I need to automate this. Any help is highly appreciated!

Comments (1)

sampei · 2020-07-13

Apologies, I have managed to solve this over the weekend. For anyone interested the code is (it was way simpler than I thought):

$Dummy.pos.x = $A.pos.x
$Dummy.pos.z = $A.pos.z
$Dummy.pos.y = $B.pos.y