Bone IK

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
edo
Posts: 0
Joined: Sat Aug 14, 2004 4:04 pm

Bone IK

Post by edo »

Sorry for my bad english.

Maybe I'm too dumb to understand why I can check if a bone has IK with hasIK() but there is no way to set IK.

It's possible or not ?
(and if the answer is yes, HOW ???)

Sorry again for my english.

kitsu
Posts: 0
Joined: Sun Jun 06, 2004 8:08 am

Post by kitsu »

ik is a bool variable of the bone, hasIk() is just a wrapper function for the Bone.bone.ik variable. Try my_bone.ik = 1 to set ik on (and 0 to turn it off).

edo
Posts: 0
Joined: Sat Aug 14, 2004 4:04 pm

Post by edo »

Tanks for the answer but this don't work.
If I try this simple script Blender say : KeyError: 'attribute not found'

Code: Select all

import Blender
from Blender import *
from Blender.Armature import *
from Blender.Armature.Bone import *

armObj = Object.New('Armature', "Armature_obj")
armData = Armature.New()

bn1=Blender.Armature.Bone.New("bone1")
bn1.setHead(0.0,0.0,0.0)
bn1.setTail(2.0,1.0,0.0)

bn2=Blender.Armature.Bone.New("bone2")
bn2.setHead(3.0,2.0,1.0)
bn2.setTail(4.0,4.0,1.0)
bn2.setRoll(.5)
bn2.setParent(bn1)
bn2.ik = 1

bn3=Blender.Armature.Bone.New("bone3")
bn3.setHead(5.0,6.0,2.0)
bn3.setTail(5.0,8.0,2.0)
bn3.setParent(bn2)

armData.addBone(bn1)
armData.addBone(bn2)
armData.addBone(bn3)

armData.drawAxes(1)
armObj.link(armData)

scn = Blender.Scene.getCurrent()
scn.link(armObj)

armObj.makeDisplayList()
Blender.Window.RedrawAll()
Maybe I'm really TOO dumb :cry:

kitsu
Posts: 0
Joined: Sun Jun 06, 2004 8:08 am

Post by kitsu »

I tried it too, I guess the ik attribute is read only? Seems odd.

edo
Posts: 0
Joined: Sat Aug 14, 2004 4:04 pm

Post by edo »

I'm the only one interessed in a setIK function ???

ascotan
Posts: 0
Joined: Thu May 29, 2003 10:32 pm
Location: Maryland, U.S.

Post by ascotan »

I started to write the set/unset IK feature however the code became too cumbersome and I had to finish other parts of the armature module. Therefore this became a read-only flag. There used to be a 'flags' for the bone that you could access this var so this just fufilled some functionality that was already there.

edo
Posts: 0
Joined: Sat Aug 14, 2004 4:04 pm

Post by edo »

Thank you for your answer.

Do you think we can see this function in 2.35 ?

dandeloreon1984
Posts: 0
Joined: Wed Jan 21, 2004 11:12 pm
Contact:

Post by dandeloreon1984 »

i also need this to be enabled to do some more complex work, but at least now i know what is happinin. :).

ascotan
Posts: 0
Joined: Thu May 29, 2003 10:32 pm
Location: Maryland, U.S.

Post by ascotan »

Yes since this is being requested :) I think we need to work on this again. The prob was that the code for armatures + python is pretty complex. The biggest issue is that bones store their 'temp' vaules in a axis/angle format (although simple is sort of a headache). However when drawn to screen they are transformed to a matrix through some internal functions (translation can be head or tail depending on how the func is used). To get IK and the roll fixed we'll need to deconstruct the parented matrix back to a 'worldspace' axis/angle. At this point my brain gave out :? However once this is done both the roll issue and the IK issue can be solved.

Post Reply