Notifications
Clear all

[Closed] copy/paste position & rotation with maxscript

Hi,
i’m really a newbie in scripting with Max, but i try to make one for copying local position and rotation of an object from his parent (wherever you are on the timeline) and paste these values on another object at any frame.
i just want to do something like copy/paste pose of biped

if anyone can help me, thx

6 Replies
1 Reply
(@rustyknight)
Joined: 11 months ago

Posts: 0

The eaiest way I can think off straight up, would be to grab a copy of the objects “transform” property and assign that value to the other object.


   trans = nodeA.transform
   nodeB.transform = trans
 

The immediate problem that bounces to mind, is that this version will cause nodeB to share the exatct same space as nodeA (position and rotation) in the scene.

(
     local pos
     local rot
     in coordsys parent (
         pos = $Box02.position
         rot = $Box02.rotation
     )
     
     $Box03.position = pos
     $Box03.rotation = rot
 )

This will take the position and rotation, relative to the parent and apply it to the second object.

You would be wise to apply the value within the parent context of the second object, but it will depend on what you are trying to do.

Shane

Hi Shane,
thanks for answering me. sure it’s gonna help me
in the second script, the box03 and box02 names represent specific objects? but if it’s to copy on a selected object and paste it on another one, should i call them nodeA and nodeB as you have written in the first?

It don’t think it really matters, the first exmple is more psudo code then actual code…

For example, you could do something like this:


   -- Check to see if we have anything selected
   if selection.count == 1 do (
 	-- Allow the user to select the object to be copied to
 	local objToCopyTo = pickObject message:"Please select the object to be copied to" rubberband:$.position
 	-- Make sure that the user selected something...
 	if objToCopyTo != undefined do (
 	  -- Cut & pasted from before...
 	  local pos
 	  local rot
 	  in coordsys parent (
 		pos = $.position
 		rot = $.rotation
 	  )
 	 
 	  objToCopyTo.position = pos
 	  objToCopyTo.rotation = rot	
 	)
   )
 

ooh that’s cool thanks, i think i will just have to do some adjustements but that’s what i wanted to do!
do you know some sites or books that can help me improving my scripts ?

Remi

1 Reply
(@rustyknight)
Joined: 11 months ago

Posts: 0

ScriptSpot, anything by Bobo, he has some work on scriptspot, but I don’t recall the address, http://paulneale.com/ and you might also want to check out cgacademy as well

Shane

thks for the links
i have a script with labels and buttons that function now thx to you
there’s just a last detail. when i copy rotation values with the following code :


in coordsys local (

SelRot = quatToEuler ($.rotation)

crx.text = SelRot.x as string

cry.text = SelRot.y as string

crz.text = SelRot.z as string

)


i ‘ve got values in quaterniion so that i transform them in Euler. but when i try to paste them, it seems like there is a difference between the conversion or maybe the coord system is not good, but the rotation in XYZ isnn’t properly the same…
past code :

 
in coordsys parent (

locx = -cpx.text as float

locy = -cpy.text as float

locz = -cpz.text as float

$.rotation = eulerAngles locx locy locz

)