[Closed] change animationrange depending on the animated object to export
Hi guys!
I can´t find the way to do that, maybe its not possible.
I´m wondering how I could automatically set the animationrange depending on the first and last keyframe of my selected object, but I can´t figure out how to do it, I don´t find the way to get that first and last keyframe information of the selected object. Any clue?
Thanks a lot!
select your object and then try this :
myObj = $
startF = #()
endF = #()
findPositionKeys = myObj.position.controller.keys
append startF findPositionKeys[1].time
append endF findPositionKeys[findPositionKeys.count].time
findStartFrame = (amin startF)
findEndFrame = (amax endF)
animationRange = interval findStartFrame findEndFrame
IT WORKS!
Thank you so much Siahpoosh! I owe you one mate!
It’s going to be fun now… This works for position only, so now I should do it work with rotation and scale keys, check which one it the lowest value, which one the highest so that’s going to be the animationRange and do it work for single objects and for groups too.
I hope not too but maybe I’ll need your help again…hehe
Really, thank you so much for your help, with this firts step I think I would be able to achieve what I want
with the help of a friend i have achieved this, which works with single and group objects
counter = 1
posStartF = #()
posEndF = #()
rotStartF = #()
rotEndF = #()
sclStartF = #()
sclEndF = #()
for obj in $ do
(
try
(
findPositionKeys = obj.position.controller.keys
append posStartF findPositionKeys[1].time
append posEndF findPositionKeys[findPositionKeys.count].time
)
catch
(
append posStartF 99999
append posEndF 0
)
try
(
findRotationKeys = obj.rotation.controller.keys
append rotStartF findRotationKeys[1].time
append rotEndF findRotationKeys[findRotationKeys.count].time
)
catch
(
append rotStartF 99999
append rotEndF 0
)
try
(
findScaleKeys = obj.scale.controller.keys
append sclStartF findScaleKeys[1].time
append sclEndF findScaleKeys[findScaleKeys.count].time
)
catch
(
append sclStartF 99999
append sclEndF 0
)
counter = counter + 1
print counter
)
findPosStartFrame = (amin posStartF)
findPosEndFrame = (amax posEndF)
findRotStartFrame = (amin rotStartF)
findRotEndFrame = (amax rotEndF)
findSclStartFrame = (amin sclStartF)
findSclEndFrame = (amax sclEndF)
valueMin = #(findPosStartFrame,findRotStartFrame,findSclStartFrame)
totalMin = (amin valueMin)
valueMax = #(findPosEndFrame,findRotEndFrame,findSclEndFrame)
totalMax = (amax valueMax)
if totalMax == 0 then
(
animationRange = interval 0 1
)
else
(
animationRange = interval totalMin totalMax
)