[Closed] Ignore empty frames
I don’t want to interfere with your learning process but if you like I could show how to script this kind of tasks…
here is a basic function to get at key position the value of a controller:
fn getRotationData node =
(
for k in node.rotation.controller.keys collect at time k.time #(k.time, node.rotation)
)
if you want to collect only data on some particular time interval we can add the condition:
fn getRotationData node range:animationrange =
(
for k in node.rotation.controller.keys where k.time >= range.start and k.time <= range.end collect at time k.time #(k.time, node.rotation)
)
usually it’s much cleaner to return data in some readable format… the way of doing this is the using of structures:
struct KeyValue (time, value)
fn getRotationData node range:animationrange =
(
for k in node.rotation.controller.keys where k.time >= range.start and k.time <= range.end collect at time k.time (KeyValue time:k.time value:node.rotation)
)
if we want to have an option of using or not using time interval we can add new condition (#allKeys for example):
struct KeyValue (time, value)
fn getRotationData node range: = if isvalidnode node do
(
if range == unsupplied do range = animationrange -- default interval
for k in node.rotation.controller.keys where range == #allKeys or (k.time >= range.start and k.time <= range.end) collect at time k.time (KeyValue time:k.time value:node.rotation)
)
/*
-- samples:
getRotationData $ -- get keys on animation range interval for selected node
getRotationData node range:#allKeys -- get all keys for specified node
getRotationData node range:(interval 20 40) -- get keys on specified interval for specified node
*/
it’s the basic. but in real life the task is more complicated. usually the save animation function has to collect not only values of controller but also key parameters (in/out tangent type, in/out tangent value, etc.), and type of controller. only this can more or less guaranty that saved and loaded animation will be close enough.
and of course before collecting the data we have to check that inspected controller is animatable and keyable.
fn getRotationData node range: = if isvalidnode node do
wow, I never saw this syntax
It’s printing very well now:
(keyValue time:0f value:(quat -0.0084074 -0.726134 -0.0760803 -0.683279))
(keyValue time:6f value:(quat -0.0083271 -0.730019 -0.0814009 -0.678511))
(keyValue time:14f value:(quat -0.0083271 -0.730019 -0.0814009 -0.678511))
(keyValue time:20f value:(quat 0.00883731 -0.735388 -0.117566 -0.667311))
(keyValue time:30f value:(quat -0.0290219 -0.73919 -0.149244 -0.656111))
(keyValue time:51f value:(quat -0.0290223 -0.73919 -0.149243 -0.656111))
(keyValue time:59f value:(quat 0.0431588 -0.746856 -0.156649 -0.644829))
(keyValue time:70f value:(quat 0.043159 -0.746856 -0.156649 -0.644829))
(keyValue time:76f value:(quat -0.029703 -0.742674 -0.166747 -0.64788))
(keyValue time:81f value:(quat -0.023978 -0.720314 -0.0932344 -0.686935))
(keyValue time:87f value:(quat -0.0138081 -0.709417 -0.0797173 -0.70013))
(keyValue time:92f value:(quat -0.00840715 -0.726134 -0.0760805 -0.683279))
but I would like to see like I wrote:
sliderTime = 0f
$.rotation = (quat -0.0402838 -0.692195 0.0462476 -0.7191)
$.pos = [0.0814999,4.36233e-005,-0.00849035]
sliderTime = 1f
$.rotation = (quat -0.0398559 -0.692551 0.0462876 -0.718778)
$.pos = [0.0819329,0.000305913,-0.00848681]
sliderTime = 3f
$.rotation = (quat -0.0373623 -0.694563 0.0465611 -0.716951)
$.pos = [0.0844062,0.0018139,-0.00846642]
sliderTime = 5f
$.rotation = (quat -0.0348128 -0.696512 0.0469076 -0.715163)
$.pos = [0.0868516,0.00332114,-0.00844604]
sliderTime = 8f
$.rotation = (quat -0.0343639 -0.696845 0.0469752 -0.714856)
$.pos = [0.087274,0.00358315,-0.0084425]
sliderTime = 10f
$.rotation = (quat -0.0343639 -0.696845 0.0469752 -0.714856)
$.pos = [0.087274,0.00358315,-0.0084425]
Why? I need apply this information to another object because I don’t know how I can write Copy and Paste function
Try looking for the “format” command. Here’s an example :
format "% : %
" valueName value
But as DenisT was saying, this doesn’t copy the keyframes tangents, so you’ll certainly encounter artefacts.
just make a decision. one is to go your own way, the another one is to do respect somebody’s else experience.