I'm creating a real learning human baby in Blender Cycles. To create the "brain" or "AI" I must of course use code. But, can I run code in Cycles mode? I don't want to be in BGE mode. P.S. I don't need interactivity.

For example I'll need the code to move armatures, get numbers from a accelo-meter in the baby and use the numbers in the code, etc.


1 Answer 1


Using python you can create an animation that can be played back and rendered using any render engine at a later time.

bone.rotation_euler.x = 15.0
bone.keyframe_insert('rotation_euler', frame=10)

As you want to read external data while creating your animation you might want to look at using the subprocess module to keep blender responsive.

Without wanting interactivity you could capture your data to a text file and have your script read it in to create the animation.

with open('mydata.csv') as csvfile:
    inFile = csv.reader(csvfile)
    for row in inFile:
        bone.rotation_euler.x = row[1]
        bone.rotation_euler.y = row[2]
        bone.rotation_euler.z = row[3]
        bone.keyframe_insert('rotation_euler', frame=row[0])
  • $\begingroup$ Are you suggesting for me to use BGE and then render in ex. Cycles? I don't want to use BGE, it has worse Physics than Cycles does and doesn't allow Constraints. $\endgroup$ Commented Jun 21, 2017 at 12:53
  • $\begingroup$ No, nothing there refers to the game engine. You can use python to keyframe an animation the same as you can do by hand. $\endgroup$
    – sambler
    Commented Jun 22, 2017 at 4:05
  • $\begingroup$ "python to keyframe an animation the same as you can do by hand" But can the code change, grab numbers from sensors, use those, update etc as I originally asked in my question? $\endgroup$ Commented Jun 22, 2017 at 5:29
  • $\begingroup$ The second example reads data from a file, you can change that to accepting data from a network connection or from a serial port.... whatever python is capable of using to get data. $\endgroup$
    – sambler
    Commented Jun 22, 2017 at 5:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .