ScriptSpot

Forum topic · General Scripting

alignPivot <node> function

By jeanfabre · 2010-05-27

Description

Hi Everyone,

first post, with hopefully a simple question:

I can't seem to make alignPivot function work

extract from the help:
"Same as Hierarchy/Pivot/Affect Pivot Only - Align to Object."

the help doesn't provide any example unfortunatly.

I tried to select an object in the scene then type alignPivot $otherObject. It return true, but did not do anything.

My problem is that for this function to work, I need to provide two nodes, the source and the target, but the function signature only has one variable... how to how define the second node?

I can't find any example when I google for it...

Does any one know how to use this function within a script?

Thanks!

Jean

Comments (3)

lutteral · 2010-06-02

try this:



alignFrom.objectOffsetRot = alignTo.rotation -- rotate the object away from its pivot
rotate alignFrom alignTo.rotation -- puts back the object in the original orientation, leaving the pivot oriented like the target object
alignFrom.pivot = alignTo.position -- move the aligned pivot to the target's position

obviously, alignFrom and alignTo are the objects you want to use.

or wrap it in a handy function:


fn alignMyPivot sourceNode targetNode =
(
sourceNode.objectOffsetRot = targetNode.rotation
rotate sourceNode targetNode.rotation
sourceNode.pivot = targetNode.position
)

There's no such thing as a scale for a pivot point, so, you should be ok with this.
enjoy,

jeanfabre · 2010-05-27

Hi Le1setreter

This is only setting the position, but what about the rotation and scale values of the pivot point? I could do without the scale, but after having messed with offsetrot and all that, I still can't figure out how to do it properly.

If there is another way to align a pivot transform of a node to another, I am all hear, but if there is a function already documented, maybe this would be better.

Bye,

Jean

le1setreter · 2010-05-27

try this:


$object1.pivot = $object2.pos