Pydrivers 101

Trying to get to rips with Pydrivers.

Why doesn’t my example work? I’m wanting the cube Z movement (LocZ) to copy the cone.

Next question: I will want to know how to make a shapekey follow LocX (etc) of a single Armature bone and am not sure what to link it to.

Thanks for anyone who can help.

.

Attachments

mypy01.blend (36.1 KB)

Actually it works for me fine, but Cone has to move far enough along Z-axis to see Cube moving.
I made little tweak to values under Cube’s driven channel ( changed animation curve ) so you can compare with your original IPO and play with it to see how it works.
Second question I can’t answer - I don’t know.

Blend:

Attachments

mypy01_b.blend (36.1 KB)

Thank you jawra… I hadn’t realised someone had answered this and also got something working by altering the IPO curve. Here’s what I was writing in response, along with a new question…

Apparently I had everything on the py-side right. The problem was that I thought the python values would read from realworld positions whereas they were in fact reading values from the IPO curve. By fixing the curve to a constant, cyclic extrapolation (e.g. diagonal line where x=0,y=0 x=1,y=1 etc) the cube follows the cone as expected. My previous example would have been moving but only the tiniest amount and at a very tight range.

Question
: I’m assuming from this that pydrivers must go through the IPO curve and I can’t just have python read world / local XYZ directly?

.

Attachments

mypy02.blend (36.1 KB)

Thanks for sharing.


Little Tom: Your mother wants you to take home Disney dvd collection, family guy dvd, the simpsons dvd season and south park dvd. Be quick, she is waiting.

Name says everything IPO driver - so, no IPO curve, no IPODriver(pydriver). IPODrivers, including pydrivers just give X axis position on IPOCurve, then Blender reads Y value from driven IPOCurve. No direct value passed to object, it’s just animation driven by IPODriver instead of frame change. To copy direct value you can use constraints or do it via ScriptLinks. With normal IPODriver you can use only one property(e.g. LocX). With pydrivers you can mix different properties from various objects and do some math operations.
In .blend some examples of driven IPOs where animation of various objects depends on position (animation) of driving object.

Attachments

Driven_IPOs_01.blend (33.4 KB)

Haha - that’s crazy. Nice clear example. Thanks also for the explanation.

Now I have answer. It was so simple :eek:. No pydrivers just simple IPO driver. It was fun to discover that. I’m still learnig new stuff.

Attachments

Bone2ShapeKey.blend (32.6 KB)

Yes, that will work.

The reason I was originally asking though was because I wanted to know the pydriver to the armature by name. If I can link the armature through a pydriver function then it makes it possible (in theory) to have combinations of bones multiplied / added / subtracted etc to perform 2D manipulations.

So you see, if I could do this through pydrivers (as opposed to straight pose-based IPO) then it could help me to solve the controller puzzle in the other thread you have been helping in: http://blenderartists.org/forum/showthread.php?t=181253

This thread was initially set up to try and pinpoint a howto of the specific part I was stuck on, before I decided to make a broader example (the green alien with eye controllers) so people could know what I was really aiming for.

Now I see, but since I’m not coder and my Python is much worse than my English I can’t help you now.
Following the thread about accessing bones via pydriver you linked to, it may be not so easy. Some time later I’m going to take a look at some scripts and maybe find solution.
Regards.

Adam

That would be cool. I am also not a coder and very much appreciate the effort you’ve been putting in.