Hi am a noob to scripting in python, I’m doing some research to see if blender is a viable option for my students to use next year. I have managed to piece together a code from various sources that first creates and then animates a cube to move along the x,y,z axis’s. This works great!!! & I have included the code, But its not quite enough for students to allow students to produce a soley coded scene to show off their coding ability.
What I’m hoping to figure out how to do is to add rotation to the animation of the cube. I want it to rotate in key frames using only python to do this (as I have done for the location keyframes). Any help would be much appreciated as I have been looking for some time for information to solve it myself but no luck.
import bpy
verts = [(-1, -1, -1), (-1, 1, -1), (1, 1, -1), (1, -1, -1), (-1, -1, 1), (-1, 1, 1), (1, 1, 1), (1, -1, 1)]
faces = [(0,1,2,3), (0,1,5,4), (1,2,6,5), (2,3,7,6), (3,0,4,7), (4,5,6,7)]
me = bpy.data.meshes.new("cubey")
ob = bpy.data.objects.new("cubey", me)
ob.location = (5.0, 5.0, 5.0)
ob.keyframe_insert(data_path = "location", frame = 0.0, index= 0)
ob.keyframe_insert(data_path = "location", frame = 0.0, index= 1)
ob.keyframe_insert(data_path = "location", frame = 0.0, index= 2)
ob.location = (-5.0, 5.0, 5.0)
ob.keyframe_insert(data_path = "location", frame = 20.0, index= 0)
ob.keyframe_insert(data_path = "location", frame = 20.0, index= 1)
ob.keyframe_insert(data_path = "location", frame = 20.0, index= 2)
ob.location = (0.0, 0.0, 0.0)
ob.keyframe_insert(data_path = "location", frame = 40.0, index= 0)
ob.keyframe_insert(data_path = "location", frame = 40.0, index= 1)
ob.keyframe_insert(data_path = "location", frame = 40.0, index= 2)
bpy.context.scene.objects.link(ob)
me.from_pydata(verts, [], faces)
me.update(calc_edges=True)
me = bpy.context.object