Notifications
Clear all

[Closed] How to add key at current fram

Hi everyone
i need an script that keys $ at the current fram of timeslider
also how can i mirror an object to the other,i mean for example one obj has a value of transformation
i wanna get the mirror of that and asign that to the other obj in the scene and have a local or
world center to do the mirror.
i was wondering if you guys could help me out,and say me the of doing those i said
thanks,
Ehsan.

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

Posts: 0

JHN is right, you’re original post is a little vaguge, but mirroring is actually rather easy.

scale $ [-1, 1, 1]

will mirror that currently selected object on the x-axis…that’s what I’ve found any way…

 JHN

You need to be more specific… Hitting the “k” key also keys the selction on current frame. What is it you need?

Also mirroring, you want to mirror the transform? On which axis, I mean what’s the mirror plane?

-Johan

 JHN

RustyKnight, scaling along 1 axis will flip the normals, I think you are aware of this, but just thought I point this out… a reset xform will fix this… or a function that reads out the new transform and just moves to the resulting coordinates and apply a mirror modifier or something…

-Johan

1 Reply
(@rustyknight)
Joined: 11 months ago

Posts: 0

Actually, I wasn’t entirly awear (but I appriciate the assumption)…it’s not a solution I like…I tend to not like scaling anything if I can help it.

I like the idea of the mirror modifier though.

Shane

hi ehsan,

check out the Controller Key Functions” topic in MXS help

the function-

addNewKey <controller> slidertime

will perform what you asked.

also – this reset xform script was lifted from the help too – I just added a few lines to flip normals and revert mirrored objects in preparation for occlusion baking.

macroscript OcclusionBakeFix
 
 	category:"Tools" 
 	tooltip:""
 (
 
 fn resetXFormU obj = 
 	(
 		local ntm = obj.transform
 		obj.transform=transMatrix obj.pos
 		local piv=obj.objecttransform * inverse obj.transform
 		obj.objectoffsetPos  = [0,0,0]
 		obj.objectoffsetRot = (quat 0 0 0 1)
 		obj.objectoffsetScale = [1,1,1]
 		ntm.translation=[0,0,0]
 		ntm = piv * ntm
 		local xformMod=xform()
 		addmodifier obj xformMod	
 		xformMod.gizmo.transform=ntm
 		ok
 	)
 
 on execute do
 	(
 	with redraw off
 	(
 		for t = 1 to selection.count do 
 			(
 			resetXformU selection[t]	
 			modPanel.addModToSelection (Normalmodifier ()) ui:on
 			selection[t].modifiers[#Normal].flip = on	
 			macros.run "Modifier Stack" "Convert_to_Poly"
 			GC()
 			)
 	)
 	)
 )

thanks JHN,RustyKnight,pudgerboy

pudgerboy i cheaked that out but there is no function to addkey in the current frame of timeslider,the why i asked it is to be able to add my keys to the curent fram ,not a specific fram for example fram 50,any way thanks to answer, for the mirror question i said

if you have a look at the attached image you will find what i mean,changed transform of green circles of the left isde of viwe should be mirrored to the blue circles of right side.

if could help with that,i’ll be aprociated.

1 Reply
(@rustyknight)
Joined: 11 months ago

Posts: 0

pudgerboy’s addkey will work, it’s, from what you’ve said, exactly what you want…

[left]sliderTime
[/left]
[left]Lets you get and set a Time value that defines the time associated with the 3ds Max time slider.

[/left]

[left]addNewKey <controller> <time> [ #select ]
[/left]
[left]Adds a new key to the controller track at the time specified. The value for the new key is the interpolated controller value at the specified time. The new key is also selected if the #select optional argument is specified. The value for the new key is the interpolated controller value at that time. addNewKey() will not add a key if a key already exists at the specified time. The return value in this case is the key located at the specified time.

Therefore addNewKey <controller> sliderTime will add a key to the selected controller at the current frame/time.

As for the mirror function…I still have no idea what you are talking about – but that’s not all that surprise…

Shane
[/left]

slidertime is a 3dsmax time global, and updates every time you move the timeslider. you can see this by entering slidertime and evaluating it each time you move the timeslider – it will return the frame on which the slider is residing.

it works well,and solved my problem,thanks again guys ,and thanks pudgerboy.