I have a collection of meshes. I want to insert keyframes to all of them. I can obviously write a 'for' loop to do this. However, to keep the code short, I was trying to use a generator expression like this:

(keyframe_insert(data_path = "location", frame = 1) for ob in col.objects[:])

I am not able to add the keyframes this way. All I am getting is a generator object in return:

<generator object <genexpr> at 0x000001754B1CCB48>

Can someone please tell me what I am missing?

  • 1
    $\begingroup$ Very much a generic python question. Need to consume the generator. (via formentioned for loop for instance) djangostars.com/blog/… Using a list comprehension instead [i for i in sequence] will create a list of keyframe insert success $\endgroup$
    – batFINGER
    Jun 17 '21 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.