Armature Tentacles

Hello Everyone!
I’m trying to make moving tentacles out of armature using python. this is what I’ve come up with so far:
import Blender
from Blender import *

Sceen= Scene.GetCurrent()
pose = arm_ob.getPose()

act = arm_ob.getAction()
if not act: # Add a pose action if we dont have one
act = Armature.NLA.NewAction()
pbones = pose.bones.values()

startframe = 1
endframe = 2000
intervall = 40

for i in range(startframe,endframe+1,intervall):
for p in range(5):
pbones[p].quat[:] = 1.000,Blender.Noise.random(),0.000,Blender.Noise.random()
pbones[p].insertKey(arm_ob, i, Object.Pose.ROT)

I’m having problems with the rotation though. The armature moves alright, but if I connect it to a mesh it deforms in bad ways. Please Help


Hello again.
I’m really going to need help with this one, I’ve changed the code a bit and attached it to an example blend file: