[Closed] again save and load animation
ok , i must over worked lastly , yes over 36 hours without sleep continuous work make real effect ,it was quite simple issue ,so here s a working script
(local source=for u in $ss* collect u
local destination=for u in $bb* collect u
local srce=for o in source collect o.name
local destn=for o in destination collect o.name
select source
LoadSaveAnimation.saveAnimation "D:\lolo.xaf" (selection as array) #("obbah") #("obbah") animatedTracks:true includeConstraints:true keyableTracks:true SaveSegment:true segInterval:(interval 0 100)
clearselection()
select destination
for u in 1 to selection.count do (selection[u].name=srce[u])
LoadSaveAnimation.loadAnimation "D:\lolo.xaf" (selection as array) insert:true relative:true insertTime:0 stripLayers:false
for u in 1 to selection.count do (selection[u].name=destn[u]) )
wanted to share my solution , thank you
oh! you paid a big price… it’s more than 3.5 hours per line of code. so where was the snag?
ok the snag was just arranging the process of naming and selection just it , and i discovered it when i tried that out of the real code on small objects , now i reconstructed it into my code and it worked like a charm on a complex set up , the only thing that seems to be not working well is that , if u have sat up more than one parameter block it just saves the first parameters the next are not seen , other than that i m quite happy
BTW ididnt spent all the 36 hours (38 indeed) on that script only 6 of them but they were the last of them , so really tired i was , any how thank you Denis !
ah! i’ve remembered! there is a bug in LoadSaveAnimation.loadAnimation. it doesn’t parse the file if any of userAttributes has empty string value. so when you save a animation you have to add any userAttribute with any value other than empty.
i really did noticed that you may check my last code above , what i say : if you have added to your attributes 3 parameters blocks like this
parameters param rollout:roll1
( … ui:(sp,sl)
)
parameters param rollout:roll2
( … ui:(sp2,sl2)
)
parameters param rollout:roll3
( … ui:(sp3,sl3)
)
it doesnt record anything other than the first parameters block !
you can say what has to be saved using LoadSaveAnimation.setUpAnimsForSave. you can specify all subanims from any param block.
i don’t have max now to check but as i remember the interface saves all param blocks, but doesn’t load (if you do it manually it doesn’t load too). but the way to get it is use LoadSaveAnimation.setUpAnimsForLoad and LoadSaveAnimation.loadAnimationNodeAnim. see mxs help for more details.
you’ve replied too quick… maybe it needs another 36 hours to arrive at a right conclusion
oh my denis ! you are acting like chinese kong fu master !
i really did try it , what i ve done is just putting the LoadSaveAnimation.setUpAnimsForSave line just before the save line as its name imply it s preparation and the help has no clue for it ,so i replied just after i did try ,i also tried the thing manually and nothing different although i dont know what is manually is the coun terpart of setUpAnimsForSave ,
here s the code anyway
[b]
with undo on
with redraw off
local source=#()
local destination=#()
tempo=amin ls1.items.count ls2.items.count
for u in 1 to tempo do (a=execute ("$"+ls2.items[u])
append source a )
for u in 1 to tempo do (a=execute ("$"+ls1.items[u])
append destination a )
local srce=for o in source collect o.name
local destn=for o in destination collect o.name
select source
LoadSaveAnimation.setUpAnimsForSave (selection as array) animatedTracks:true includeContraints:true keyable:true
LoadSaveAnimation.saveAnimation "D:\Constrainer.xaf" (selection as array) #("obbah") #("obbah") animatedTracks:true includeConstraints:true keyableTracks:true SaveSegment:true segInterval:(interval start.value end.value)
clearselection()
select destination
for u in 1 to selection.count do (selection[u].name=srce[u])
LoadSaveAnimation.setUpAnimsForLoad (selection as array) includePB2s:true stripLayers:true
LoadSaveAnimation.loadAnimation "D:\Constrainer.xaf" (selection as array) insert:true relative:true insertTime:0 stripLayers:true
for u in 1 to selection.count do (selection[u].name=destn[u])
[/b]