Align object by script
Hello,
I want to use the Align tool (in the Main Toolbar) by script. I tried to use only the transform information at the first time, but in some cases it's not worked. The Align tool works in every cases.
I searched a lot for script command to achieve the result of Align tool in the Main Toolbar, but there was no any opportunity.
So my question: How can i align one object to the other by script line? (position, orientation, etc.)
Comments
Dannat121, thanks the tip,
Dannat121, thanks the tip, but the IK - FK changing is about that you can control two type of ARM rig, and both of them can get the position of the other, but can't follow it. As I know the change handler is the best when the secondary object does the same transform like the main object. But in my case there is no following, only getting position and rotation for one time.
Otherwise if we can't get the right position and rotation for one time by script (like Align tool in max in this case when a RIG makes the contacts a bit more complicated), the change handler's tasks are in the same trouble when we just only set/get pos. and rot.
you should look into using
you should look into using Change Handlers. I think that this may help you on what you need.
when transform <--(This means POS, Rotation, and Scale) changes do
(
$Sphere01.radius = $Sphere02.radius
)
So whenever you change the object $Sphere02.radius the object $Sphere01 radius changes with it. You can set it up to start when you pick one obj then pick another. Remember you must delete the handler when you are done because i believe this is a global fn and you don't want this to calculate everytime you select two objects. I believe to end it you can put the function deleteAllChangeHandlers()
Thanks br0t the tip, i tried
Thanks br0t the tip, i tried it, but unfortunately it not works as well.
However it seams that the problem is the Pivot point.
My problem in pictures: http://matyas-vegh.com/align_problem.jpg
As you can see when we invert the transform matrix we got the right result. The most interesting is that the Align tool works perfectly in this case as well... i don't know how...
wooord! I also think its
wooord! I also think its ridiculous.
Maybe these lines can help you deal with aligning rotations, its just an edited version of the function in the help files that you can find when searching for "setNodeWorldRotation":
Cheers
Never get low & slow & out of ideas
Thanks the
Thanks the reply,
Unfortunately the "rotation" and the "position" aren't works in the cases when the transform data turns into inverse.
I want to use this solution on a character's RIG (IK-FK changing at the Arm), so a bit more complicated the definitions of location and rotation. However the Align works perfectly in these cases as well, so this is why i want to use it.
I think a bit ridiculous that there is no command to use the standard 3dsmax Align tool by script without handling popup windows etc.
why dont you use something
why dont you use something more basic like
$Box01.rotation = $Box02.rotation; $Box01.pos = $Box02.pos
I wrote that the transform
I wrote that the transform option is not work in every cases... It means that i got the inverse of the transform. So i write that $Box01.transform = $Box02.transform, and the Box01 will move to the inverse position & rotation of Box02.
The interesting is that if i align Box01 to Box02, it works, so Box01 moves to the Box02 position and rotate to the right angle. This is why i want to use the Align option.. :)
But a perfect solution is that if you know solution to get the inverse of a "transform" as well..