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()
arm_ob= Sceen.objects.active
pose = arm_ob.getPose()

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

xbones=arm_ob.data.bones.values()
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

/Peddie

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:
http://lafons.no-ip.org/tentacles/Tentacles.zip

/Peddie