Py IPO Drivers for bones?

As I cannot get answer in standard Blender forums I would hereby ask python gurus in this python sub forum:

Sorry if I am not well informed. As I know there were introduced python IPO driver in Blender some time ago -…0/ipo-drivers/

For one python line I can use objects inputs. My question is whether python IPO drivers are ready also to work with bones of armature as a source data.

For example if I want my object to be driven by Cube Loc X I can just type on line python expression ob(“Cube”).LocX

But can Blender handle the case when instead of a Cube I want to use the value Loc X of a Bone.001 from an Armature.001 for example? Is this possible? How should the python line for IPO driver look like?

Read well. It is probably safest bet to write an external (ie. in text editor) driver function as instructed in the documentation. After this you can use the Python API access whatever data you happen to need.

Thank you very much BeBraw. Could you help me how should I specify a particular bone of an armature as I have asked hereabove.Thank you very much in advance for your kind help.

Take a look at . The latter example on the page shows how to get the object data. After you have the object data, you can access the bones. Bone contains head and tail instance variables containing their locations. Those coordinates are given in local space of the armature.

I’ve found that accessing the data for bones, particularly rotation data, is akin to doing arcane magic. There may be some recent changes to the API that make this easier, I haven’t looked in a while, but be aware that bones exist in a multitude of separate spaces, and that the data you want may only be available within a particular space.

Also, be careful using bone data to drive other bones within the same armature – there is some sort of strangeness involving the depsgraph (or so I’ve been told) that makes this a chancy thing to do, and it can mess with how the IPO drivers are updated per frame, making the drivers update improperly under certain rendering circumstances.

And I’ve found that using an extensive pydrivers script for bones can under some circumstances greatly slow the real-time playback of animations, such that it makes reaching a reasonable frame-rate for previewing motion nearly impossible.

Just a few caveats.

Thank for your hints. I see that it is more difficult than I have expected.

My idea was that one bone would blend rotatons of two bones using python IPO. (Use two copy rot constraints is not possible as more constraint have some prescribed order and two have two 50% rot constraints does not mean that they blend fifty fifty

The system of bones rotation in IPO editor is really not animator friendly. I guess it has also something common with quaternion and gimbal system.

Well, this is quite do-able of you want to take the time to learn how to get inside the rotation matrices of the various bone spaces. But they aren’t extensively documented, so you may need to spend a fair amount of time learning what’s what before you can actually start to manipulate things.

I have a very extensive pydrivers script that I use for my “Katrice” model’s armature (see the Kata thread in my sig below if you’re interested), where relative rotation between pairs of bones influences various properties like Transform, Scale and Rotation of other bones that do corrective deformations on the mesh. It’s finally working OK after months of writing, testing, trials and revisions, yet I expect I’ll find something to tweak even yet. And I had to script a workaround for the frame-to-frame update glitch during rendering. But it shows that with some persistence (and major patience!), what you would like to do can be done.

Thank you very much chipmasque for your kind help. By the way Kata is really great model :slight_smile:

Thanks, Jiri, and if you run into any roadblocks drop me a PM, I might be able to help some. I’m decidedly no expert but learned quite a bit that may come in handy for your project, I’ll gladly share what I can.