[Bf-python] Making IK flag writable in the Bone class

Jonas Petersen blenderjox at mindfloaters.de
Fri Oct 22 19:58:14 CEST 2004


Gilbert, Joseph schrieb:

>Yes ic your point, but does the bone become enlongated when this
>happens?
>  
>

To be more accurate, if bone.hasIK(True) is executed in a script, then 
the IK flag is set and the head of the bone is moved to the tail of its 
parent (instantly and visibly). Just like if you press the IK button.


>-----Original Message-----
>From: bf-python-bounces at projects.blender.org
>[mailto:bf-python-bounces at projects.blender.org] On Behalf Of Jonas
>Petersen
>Sent: Friday, October 22, 2004 1:10 PM
>To: Blender Foundation Python list
>Subject: Re: [Bf-python] Making IK flag writable in the Bone class
>
>Gilbert, Joseph schrieb:
>
>  
>
>>There is more to it than that. The reason that setIK was not
>>    
>>
>implemented
>  
>
>>was that once the flag is set the matrix of each bone must be
>>recalculated so that the head becomes attached to the tail of the
>>preceeding bone. You will be able to set the flag but it's basically
>>meaningless without the recalculation of the parent/child bone
>>    
>>
>matrices.
>  
>
>> 
>>
>>    
>>
>Yea you're right. I investigated the issue. But as far as I can tell no 
>matrix has to be recalculated. Only the head position of the affected 
>bone has to get adjusted to the position of the parents tail. This is 
>done easily by just setting its position to (0,0,0) because its relative
>
>to the parents tail anyway.
>
>I python it could be done like this:
>
>  bone.hasIK(True)
>  bone.setHead(0,0,0)
>
>Btw. you can mess up the head of an IK'ed bone the same way:
>
>  bone_with_ik.setHead(1,1,1)
>
>This is not taken care of neither. Though it will correct itself 
>automatically as soon the joint will be moved.
>
>But of course this is no excuse. So I modified the function further that
>
>it...
>
>...will not set IK if affected bone has no parent.
>...adjust head of affected bone.
>
>I implemented and tested it positively.
>
>What do you think?
>
>Regards,
>Jonas
>
>  
>
>>-----Original Message-----
>>From: bf-python-bounces at projects.blender.org
>>[mailto:bf-python-bounces at projects.blender.org] On Behalf Of Jonas
>>Petersen
>>Sent: Friday, October 22, 2004 8:10 AM
>>To: bf-python at projects.blender.org
>>Subject: [Bf-python] Making IK flag writable in the Bone class
>>
>>Hi everybody!
>>
>>I hope this ist the right place to post this...
>>
>>The IK flag in the Bone python class is read only. The only way to 
>>modify it is the corresponding button in the buttons panel. It's not 
>>possible via python.
>>
>>I modified  python/api2_2x/Bone.c so the flag can be modified via
>>python.
>>
>>For now I did it by adding an optional bool parameter to the hasIK() 
>>function that sets/unsets the flag.
>>
>>An alternative or additional way would be to make the IK class member 
>>variable writeable.
>>
>>What do you think?
>>
>>I could supply a patch if desired.
>>
>>Regards,
>>Jonas
>>
>> 
>>
>>    
>>




More information about the Bf-python mailing list