One last thing, it seems that it’s using radians instead of degrees for rotational values. Is there an easy way to adjust that?
you can use any mxs expression …
in the rotation value case it’s:
degtorad 10
10 degrees are converted to radians
I was inspired by your code denisT. This acts more like the Maya edit boxes.
- Edit time on the left, edit value on the right
- Just putting in a number is an absolute time or value
- Using ?=X where ? is an operator and X is a number will offset the value by the operator. (examples: +=10, *=5, /=2, -=1)
Warning there is barely any error checking in the code below.
To do (but probably never will. )
- Selection callback to update the edit boxes based on the selected keys.
- Always use degrees for rotation controllers
- Make it dockable in the Curve Editor
try (destroydialog OffsetSelectedKeysRol) catch()
rollout OffsetSelectedKeysRol "Offset Selected Keys" width:300 height:28
(
fn OffsetSelectedKeys pointer =
(
if (tv = trackviews.current) != undefined do
(
num_keys = 0
done = #()
numSelTracks = tv.numSelTracks()
for k=1 to numSelTracks do
(
c = tv.getSelected k
if (iskindof c FloatController) and (numKeys c > -1) and (findItem done c == 0) do
(
append done c
if (num = numSelKeys c) > 0 do
(
keys = for k in c.keys where k.selected collect k
pointer keys
sortKeys c
num_keys += num
)
)
)
#(done, num_keys)
)
)
fn changeKeys setting text control =
(
control.text = ""
offset = undefined
operator = ""
expr = filterString text "="
if expr.count == 1 do offset = expr[1]
if expr.count == 2 do
(
offset = expr[2]
operator = expr[1]
)
if offset != undefined do
(
customFunction = "mapped fn applyOffsetToKeys keys = (keys." + setting + " " + operator + "= " + offset + ")"
try(execute customFunction)catch()
undo "Key Time Offset" on
(
OffsetSelectedKeys applyOffsetToKeys
)
)
)
edittext edt_time "T: " width:120 align:#left across:2
edittext edt_offset "V: " width:120 align:#left
on edt_time changed text do ()
on edt_offset changed text do ()
on edt_offset entered text do changeKeys "value" text edt_offset
on edt_time entered text do changeKeys "time" text edt_time
)
createDialog OffsetSelectedKeysRol
This is fantastic! An automatic radToDegree operator would be great addition for sure
So I’ve been using this little script for my project throughout the last week. It’s made my life a million times easier. Thanks a million for the help. Honestly, I’m pretty mystified that Max never added a built-in function for this
Here it is with rotation support. The real head scratcher is Point3 controllers. If you have X key selected all YZ also return that they are selected.
try (destroydialog OffsetSelectedKeysRol) catch()
rollout OffsetSelectedKeysRol "Offset Selected Keys" width:300 height:28
(
fn OffsetSelectedKeys pointer =
(
if (tv = trackviews.current) != undefined do
(
num_keys = 0
done = #()
numSelTracks = tv.numSelTracks()
for k=1 to numSelTracks do
(
c = tv.getSelected k
isRotation = if superclassof (tv.getParent (tv.getIndex c)) == rotationController then true else false
if (iskindof c FloatController) and (numKeys c > -1) and (findItem done c == 0) do
(
append done c
if (num = numSelKeys c) > 0 do
(
keys = for k in c.keys where k.selected collect k
pointer keys isRotation
sortKeys c
num_keys += num
)
)
)
#(done, num_keys)
)
)
fn changeKeys setting text control =
(
control.text = ""
offset = undefined
operator = ""
expr = filterString text "="
if expr.count == 1 do offset = expr[1]
if expr.count == 2 do
(
offset = expr[2]
operator = expr[1]
)
if offset != undefined do
(
customFunction = "mapped fn applyOffsetToKeys keys isRotation = (offset = if isRotation then degtorad " + offset + " else " + offset +"; keys." + setting + " " + operator + "= offset)"
try(execute customFunction)catch(messagebox "compile failed.")
undo "Key Time Offset" on
(
OffsetSelectedKeys applyOffsetToKeys
)
)
)
edittext edt_time "T: " width:120 align:#left across:2
edittext edt_offset "V: " width:120 align:#left
on edt_time changed text do ()
on edt_offset changed text do ()
on edt_offset entered text do changeKeys "value" text edt_offset
on edt_time entered text do changeKeys "time" text edt_time
)
createDialog OffsetSelectedKeysRol
what does it mean?
Edited
Oh! I see now… Probably “pointer” is not clear name for this argument
So I just tested this out. It seems that the time offset-er is shifting the frames at the same 6.28/360 (1 / 57th) ratio as degToRad so now it’s offsetting animation frames by a much smaller amount.
@denisT Sorry for the confusion. I asked a programmer at work what a function passed as a variable was called and he said a Pointer. But doesn’t matter because execute is in global scope. I don’t need to pass it as a variable, so I just renamed it to the function name.
@LordRaidis Sorry! It’s an obvious bug after you mentioned it. I can fix it, but alas our work was in vain. The default “Key Stats” toolbar is dumb and nearly useless. The hidden “Key Entry” toolbar does exactly this functionality. The syntax is a little different than Maya. See the following page.