Get all animated frames in the interval effectively
<p>I am writing an animation export script for my scene and I need to detect only those frames where animations keys for some objects in the scene appears. I need to export only a part (time interval) of all animation.</p>

<p>Currently I am using the follow code</p>

<pre><code>keys = #()
for o in objects do
(
    join keys o.position.controller.keys
    join keys o.rotation.controller.keys
    join keys o.scale.controller.keys
)
</code></pre>

<p>to collect all keys for all objects, and then</p>

<pre><code>timeValues = (for k in keys where k.time &gt;= animationRange.start and k.time &lt;= animationRange.end collect k.time) as array
timeValues = makeUniqueArray timeValues
</code></pre>

<p>to select time interval and drop duplications.</p>

<p>But the problem is, that my scene contains about 3000 frames in total with a lot of different animated objects with position, rotation and scale keys. So keys are duplicated many times in my collection "keys" - there are about 1,000,000 keys in total.</p>

<p>I need to select keys in a small time interval (about 50 frames), but as the collection is very big it tooks long (about a minute) to select desired keys and drop duplications.</p>

<p>Is there a way to get all frames with animation keys in the specified time interval more effectively?</p>