Using World Position and Rotation Transforms of an object

Using World Position and Rotation Transforms of an object

Anonymous
Not applicable
648 Views
2 Replies
Message 1 of 3

Using World Position and Rotation Transforms of an object

Anonymous
Not applicable

I'm trying to get the world position and rotation coordinates of an object, save them in a variable, and then apply them to that object or other objects later. 

 

The result I'm looking for would be like aligning a locator in world space to the object, then on another frame, aligning the objet to the locator. I want position and rotation to be saved in separate variables in case I only want to snap only one or the other. 

 

I've been trying out different approaches but haven't found a solution. The rotation part doesn't behave the way I expect. 

 

--Save the world position and rotation coordinates to variables for later use

objPosVar = in coordsys world $.position
objRotVar = in coordsys world $.rotation

--Select a different object or move to another frame and then do this:

in coordsys world $.rotation = objRotVar
in coordsys world $.position = objPosVar

 Maybe this has to do with the Quaternion rotations, but when I apply the objRotVar to the object or another object, it hops around in space as if I changed the postion. I want this all to be done in world space so I can snap objects no matter what heirarchy they're in. 

 

Thanks!

0 Likes
649 Views
2 Replies
Replies (2)
Message 2 of 3

barigazy
Enthusiast
Enthusiast

You can simply use node transform property

Example

delete objects
locator = Point pos:[100,100,100] name:"Locator" dir:[.3,.5,.8] axistripod:on cross:off size:50
marker = copy locator
obj = Teapot pos:[-10,-20,30] dir:[-.15,-.4,.7]
locatorTM =  locator.transform
with animate on
(
	at time 10 locator.transform = obj.transform = obj.transform
	at time 20 obj.transform = locatorTM
)

 

0 Likes
Message 3 of 3

Anonymous
Not applicable

Thanks for the reply!

 

This is the exact code snippet that did what I wanted it to. Just wanted to share in case anyone else could find this useful.

 

objPos = in coordsys world $.position
objRot = in coordsys world $.rotation

in coordsys (transMatrix $.position) $.rotation = objRot
in coordsys world $.position = objPos

 

0 Likes