-
-
Save jesterswilde/cae38323c6486d2b146f to your computer and use it in GitHub Desktop.
Reloads the rig and mesh of a Max scene while preserving the animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Saves out the animation of the selected controllers, reloads the base scene and then loads the animation back on. It also saves out the file as a new iteration just in case things go pear shaped. | |
studioLib() | |
drvLibGame() | |
--collect selection in name form | |
_objNames = #() | |
if(classof $ == ObjectSet) then ( | |
for i = 1 to $.count do ( | |
_objNames[i] = $[i].name | |
) | |
) | |
else( | |
_objNames[1] = $.name | |
) | |
if(_objNames.count > 0) then ( | |
--save animation | |
_nameBits = filterstring mfn "_" | |
_animSaveName = "" | |
for i = 1 to (_nameBits.count - 2) do ( | |
_animSaveName += _nameBits[i] | |
_animSaveName += "_" | |
) | |
_animSaveName += "SavedAnimation.xaf" | |
_animSavePath = mfp + _animSaveName | |
LoadSaveAnimation.saveAnimation _animSavePath $ "" "" | |
_theTakeNum = (filterString ((filterString (_nameBits[_nameBits.count]) ".")[1]) "t")[1] as integer | |
_theTake = "" | |
if(_theTakeNum < 9) then ( | |
_theTake = "00" + ((_theTakeNum+1) as string) | |
) | |
else( | |
if(_theTakeNum < 99) then ( | |
_theTake = "0" + ((_theTakeNum+1) as string) | |
) | |
) | |
_newSaveName = "" | |
for i = 1 to (_nameBits.count - 1) do ( | |
_newSaveName += _nameBits[i] | |
_newSaveName += "_" | |
) | |
_newSaveName += "t"+ _theTake +".max" | |
--load old file | |
_newSavePath =mfp + _newSaveName | |
loadMaxFile refFile | |
--select old selection | |
_objNodes = #() | |
for i =1 to _objNames.count do ( | |
_objNodes[i] = getnodebyname _objNames[i] | |
) | |
--apply animation | |
LoadSaveAnimation.loadAnimation _animSavePath _objNodes | |
saveMaxFile _newSavePath | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment