1
$\begingroup$

I have a bone who's scale and rotation changes based on the rotation of another bone. I want the power of the driver to change, based on whether the rotation of the parent bone is in the positive or negative direction. When making a basic driver, I can get things to work how I want when the bone is rotated one way, but then the behavior is not what I want when it bends the other way. I'm using a scripted expression, transform channel, expanded polynomial generator with 1 polyorder.

$\endgroup$
1
  • $\begingroup$ What does your driver look like right now? Fcurve, scripted expression? $\endgroup$
    – Nathan
    Dec 30, 2022 at 23:24

1 Answer 1

1
$\begingroup$

if you go to the text editor -> templates -> python drivers:

you will get:

# This script defines functions to be used directly in driver expressions to
# extend the built-in set of python functions.
#
# This can be executed on manually or set to 'Register' to
# initialize the functions on file load.


# two sample functions
def invert(f):
    """ Simple function call:

            invert(val)
    """
    return 1.0 - f


uuid_store = {}


def slow_value(value, fac, uuid):
    """ Delay the value by a factor, use a unique string to allow
        use in multiple drivers without conflict:

            slow_value(val, 0.5, "my_value")
    """
    value_prev = uuid_store.get(uuid, value)
    uuid_store[uuid] = value_new = (value_prev * fac) + (value * (1.0 - fac))
    return value_new


import bpy

# Add functions defined in this script into the drivers namespace.
bpy.app.driver_namespace["invert"] = invert
bpy.app.driver_namespace["slow_value"] = slow_value

And in that function you can basically do whatever you want -> and of course as well set the second property.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .