Discussion:
[Bf-python] Attaching drivers to nodes within Node Group
Jed Frechette
2013-08-26 21:52:09 UTC
Permalink
What is the correct way to attach drivers to nodes within a node group?

I'm trying to drive a mapping node that controls the orientation of a
world texture using the rotation of an object within the scene. Everything
works as expected as long as the mapping node is not within a node group
(test_01). If it is within a group things start behaving in strange ways.
I've found a method that works, however, it is a series of ugly hacks so
I'm hoping someone can suggest a better way.

My test code got pretty lengthy so rather than attach it here it is
available on Bitbucket:

https://bitbucket.org/jedfrechette/scratch/src/tip/blender/node_group_tests.py

If I try to attach the driver directly to the node group's node tree
(test_02) the field gets highlighted to indicate it is connected to a
driver, however, no driver is listed in the graph editor and rotating the
control object has no effect.

If I attach the driver to the world node tree (test_03) I can get the
control object's orientation to drive the mapping node. To do this
however, I have to create the driver using a temporary path outside of
node group then replace it to the full path to the mapping node within the
group. In addition, the driven field is not highlighted and although the
world texture's orientation is correct when rendered it does not update in
real-time when the view port is set to 'Rendered' view. Toggling the view
port between another mode, e.g. Solid, and Rendered will update the
background's orientation. I can get the mapping node within the group to
update the background in real-time if I add a dummy mapping node outside
of the node group and attach a driver to it. This dummy mapping node does
not need to be connected to any other nodes and the driver can be attached
to any of the values on this mapping node.

Thanks in advance for any advice.
--
Jed Frechette
Loading...