0
$\begingroup$

I know how to add drivers to a cube rotation using an empty as a driver. Here's how I know:

import bpy

def add_driver(
        source, target, prop, dataPath,
        index = -1, negative = False, func = ''
    ):
    ''' Add driver to source prop (at index), driven by target dataPath '''

    if index != -1:
        d = source.driver_add( prop, index ).driver
    else:
        d = source.driver_add( prop ).driver

    v = d.variables.new()
    v.name                 = prop
    v.targets[0].id        = target
    v.targets[0].data_path = dataPath

    d.expression = func + "(" + v.name + ")" if func else v.name
    d.expression = d.expression if not negative else "-1 * " + d.expression 
    
empty = bpy.context.scene.objects['Empty']

add_driver( cube, empty, 'rotation_euler', 'rotation_euler.x', 0)

add_driver( cube, empty, 'rotation_euler', 'rotation_euler.y', 1)

add_driver( cube, empty, 'rotation_euler', 'rotation_euler.z', 2)

How do I use the same empty to add drivers to a "vector rotate(Euler)" node in rotation(x,y,z) in shader editor using python?

$\endgroup$
2
  • 2
    $\begingroup$ You should paste your actual code into the question itself, that way we can theoretically help debug it by copying it into our own blender file. Actual text helps with indexing and helps future google searches that might lead others with your problem to this question if it does get answered. $\endgroup$ Commented Nov 15, 2024 at 16:53
  • $\begingroup$ Hi Jakemoyo, it didn't paste properly the first time. I will try to paste it again. Or please tell me why a part of the script is not part of the highlighted area. Thank you. $\endgroup$ Commented Nov 15, 2024 at 18:42

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.