import bpy from math import sqrt, sin, cos import mathutils # Add an armature to the tetrahedrons bpy.ops.object.armature_add() armature = bpy.context.object armature.name = "HingeArmature" armature.location = (0, 0, 0) # Add bones to the armature bpy.ops.object.mode_set(mode='EDIT') bone1 = armature.data.edit_bones.new('Bone1') bone1.head = (0, 0, 0) bone1.tail = (-2, 0, 0) bone1.use_deform = False bone2 = armature.data.edit_bones.new('Bone2') bone2.head = mathutils.Vector((0, 0, 0)) bone2.tail = mathutils.Vector((2, 0, 0)) bone2.use_deform = False bpy.ops.object.mode_set(mode='OBJECT') # Animate the hinge frames = 30 for frame in range(frames): bpy.context.scene.frame_set(frame) angle = frame / frames * 2 * 3.14159265 bone1.tail = mathutils.Vector((-2, 0, -2)) bone2.tail = mathutils.Vector((2 , 0, 2)) bone1.keyframe_insert(data_path='tail') bone2.keyframe_insert(data_path='tail')