keydumper.ms
this script use to work well in some older versions of max but does not work with ver 8
When I run it I don't get any errors. The floaters just don't come up.
It dumps the values of your keys out.
If anyone could comment on what I might look at to change I would be so grateful.
I think I got this from Swami but there was no comment header in the ms file.
thanks
lowell
utility KeyDump "Key Dumper" (
fn dumpCtrl daController daFile = (
format "%\n" (classof daController) to:daFile
format "%\n" daController.keys.count to:daFile
case (classof daController) of (
bezier_position: (
if daController.keys.count == 0 then (
format "%\n" daController.value to:daFile
)
else (
for aKey in daController.keys do (
format "% " aKey.value to:daFile
format "%\n" ((aKey.time as float)/(1s as float)) to:daFile
)
)
)
tcb_rotation: (
if daController.keys.count == 0 then (
format "% %\n" (daController.value as angleaxis).angle (daController.value as angleaxis).axis to:daFile
)
else (
for aKey in daController.keys do (
format "% % " (aKey.value as angleaxis).angle (aKey.value as angleaxis).axis to:daFile
format "%\n" ((aKey.time as float)/(1s as float)) to:daFile
)
)
)
bezier_scale: (
if daController.keys.count == 0 then (
format "%\n" daController.value to:daFile
)
else (
for aKey in daController.keys do (
format "% " aKey.value to:daFile
format "%\n" ((aKey.time as float)/(1s as float)) to:daFile
)
)
)
)
)
fn dumpKeysFor daObj daFile = (
dumpCtrl daObj.position.controller daFile
dumpCtrl daObj.rotation.controller daFile
dumpCtrl daObj.scale.controller daFile
)
fn readKeysFor daObj daFile = (
-- reading pos
ctrl = (readValue daFile)()
daObj.position.controller = ctrl
deleteKeys ctrl #allKeys
numOfKeys = readValue daFile
if numOfKeys == 0 then (
animate off (ctrl.value = readValue daFile)
)
else (
for n = 1 to numOfKeys do (
daPos = readValue daFile
daTime = readValue daFile
newKey = addNewKey ctrl (daTime*1s)
newKey.value = daPos
)
)
-- reading rot
ctrl = (readValue daFile)()
daObj.rotation.controller = ctrl
deleteKeys ctrl #allKeys
numOfKeys = readValue daFile
if numOfKeys == 0 then (
animate off (ctrl.value = angleaxis (readValue daFile) (readValue daFile))
)
else (
for n = 1 to numOfKeys do (
daAngle = readValue daFile
daAxis = readValue daFile
daTime = readValue daFile
newKey = addNewKey ctrl (daTime*1s)
newKey.value = angleaxis daAngle daAxis
)
)
-- reading scale
ctrl = (readValue daFile)()
daObj.scale.controller = ctrl
deleteKeys ctrl #allKeys
numOfKeys = readValue daFile
if numOfKeys == 0 then (
animate off (ctrl.value = readValue daFile)
)
else (
for n = 1 to numOfKeys do (
daScale = readValue daFile
daTime = readValue daFile
newKey = addNewKey ctrl (daTime*1s)
newKey.value = daScale
)
)
)
button doKeyDump "Dump Keys" width:120
on doKeyDump pressed do (
dumpKeysFor $ (createFile ("d:/"+$.name+".keys.txt"))
gc()
)
button doReadKeys "Read Keys" width:120
on doReadKeys pressed do (
srcFileName = getOpenFileName caption:"Select a keys dump:" filename:"" types:"Key Dumps (*.keys.txt)|*.keys.txt||"
if srcFileName != undefined then readKeysFor $ (openFile srcFileName)
gc()
)
)
Comments
Thanks for taking the time.
Thanks for taking the time.
its an utility plugin. it is
its an utility plugin. it is accessible only from utility menu.
Or,
I modified the script for non-utility use. It is now just a maxscript. just run the script.
one thing to note that, this script dumps the keyfile to the root of the D:\ if you dont have a writable D:\ Drive, for ex. if your D drive is your DVD-ROM it wont work. You can find corresponding file at the end of the script and change that.
Cheers
(
fn dumpCtrl daController daFile = (
format "%\n" (classof daController) to:daFile
format "%\n" daController.keys.count to:daFile
case (classof daController) of (
bezier_position: (
if daController.keys.count == 0 then (
format "%\n" daController.value to:daFile
)
else (
for aKey in daController.keys do (
format "% " aKey.value to:daFile
format "%\n" ((aKey.time as float)/(1s as float)) to:daFile
)
)
)
tcb_rotation: (
if daController.keys.count == 0 then (
format "% %\n" (daController.value as angleaxis).angle (daController.value as angleaxis).axis to:daFile
)
else (
for aKey in daController.keys do (
format "% % " (aKey.value as angleaxis).angle (aKey.value as angleaxis).axis to:daFile
format "%\n" ((aKey.time as float)/(1s as float)) to:daFile
)
)
)
bezier_scale: (
if daController.keys.count == 0 then (
format "%\n" daController.value to:daFile
)
else (
for aKey in daController.keys do (
format "% " aKey.value to:daFile
format "%\n" ((aKey.time as float)/(1s as float)) to:daFile
)
)
)
)
)
fn dumpKeysFor daObj daFile = (
dumpCtrl daObj.position.controller daFile
dumpCtrl daObj.rotation.controller daFile
dumpCtrl daObj.scale.controller daFile
)
fn readKeysFor daObj daFile = (
-- reading pos
ctrl = (readValue daFile)()
daObj.position.controller = ctrl
deleteKeys ctrl #allKeys
numOfKeys = readValue daFile
if numOfKeys == 0 then (
animate off (ctrl.value = readValue daFile)
)
else (
for n = 1 to numOfKeys do (
daPos = readValue daFile
daTime = readValue daFile
newKey = addNewKey ctrl (daTime*1s)
newKey.value = daPos
)
)
-- reading rot
ctrl = (readValue daFile)()
daObj.rotation.controller = ctrl
deleteKeys ctrl #allKeys
numOfKeys = readValue daFile
if numOfKeys == 0 then (
animate off (ctrl.value = angleaxis (readValue daFile) (readValue daFile))
)
else (
for n = 1 to numOfKeys do (
daAngle = readValue daFile
daAxis = readValue daFile
daTime = readValue daFile
newKey = addNewKey ctrl (daTime*1s)
newKey.value = angleaxis daAngle daAxis
)
)
-- reading scale
ctrl = (readValue daFile)()
daObj.scale.controller = ctrl
deleteKeys ctrl #allKeys
numOfKeys = readValue daFile
if numOfKeys == 0 then (
animate off (ctrl.value = readValue daFile)
)
else (
for n = 1 to numOfKeys do (
daScale = readValue daFile
daTime = readValue daFile
newKey = addNewKey ctrl (daTime*1s)
newKey.value = daScale
)
)
)
--ROLLOUT
-------------------------------------------------------------
try(destroyDialog KeyDump )catch()
rollout KeyDump "Key Dumper"
(
button doKeyDump "Dump Keys" width:120
button doReadKeys "Read Keys" width:120
on doKeyDump pressed do
(
dumpKeysFor $ (createFile ("d:/"+$.name+".keys.txt"))
gc()
)
on doReadKeys pressed do
(
srcFileName = getOpenFileName caption:"Select a keys dump:" filename:"" types:"Key Dumps (*.keys.txt)|*.keys.txt||"
if srcFileName != undefined then readKeysFor $ (openFile srcFileName)
gc()
)
)
createdialog KeyDump 150 70
-------------------------------------------------------------
)
www.ardakutlu.com