Is there a way to set a global variable and to use it in the Node Editor?

Hello

Is there a way to set a global variable and to use it in the Node Editor?

For example: I have many materials on different objects with different colors. I setup a Groupnode which allows me to set the V of the HSV Colormodel. I use this groupnode to assigne the colors in the materials. Now my idea was to have a global variable and to connect it to the V of the Groupnode. So I would be able to darken all colors setuped wit the Groupnode in one changing (in changing the global variable). Sorry about my English :-).

Thank you very much for your help.

You could use drivers… But drivers don’t act on elements inside Nodegroups (they act, but cycles doesn’t update nodes inside nodegroups), so you’d need to add the driver to the nodegroup interface in all your materials.

And if the driver gets the value from a custom property, the property can’t be on scene or world for some reason

You can try scripting, NodeGroup is the name of your group node.
Past code to Blender text editor and run it.


import bpy


bpy.data.node_groups['NodeGroup'].nodes['Hue Saturation Value'].inputs[2].default_value = 1

Thank you for your answers.

Now I have to read me through the theme “drivers”, which I have not used till now.

That looks interesting. Thank you very much. I will try that first.

I tried this, but it changed so far only the default_value and not the value in the input Group.

I would like to change the value of BewusstheitsValue.
My attempt so far:

[QUOTE]


bpy.data.node_groups['Bewusstheit'].inputs[1].default_value = 0.3

[/QOUTE]

you should change the value in the particular node inside the nodegroup (as JuhaW posted), and not the nodegroup input. The Inputs/outputs default_values are for the instances of the node group; to change all nodegroups, you must perform the changes inside the nodegroup.
Also the socket to be changed should be disconnected, so that the default_value is not overwritten.

i think you need to go into edit mode for the material first for cycles
then change nodes values

I think this feature is on things to do in 2.8

happy cl

Some stuff in Cycles nodes can be accessed through data-blocks in the outliner. It’s a bit round-about and a PITA to find things (being honest - the process isn’t as easy as it should be. If it were easy the driver would just go on the node.), but it does let you apply drivers that way. You’ve really got to dig through the tree list for materials, and then scroll all the way down for cycles nodes, and the specific node property you’re trying to add a driver to. Driver isn’t applied to the node in the layout editor but to the property under the input value for the data-block. (However you can watch the node editor to see if the property changes, if it does you have the right one set.)

Still doing it that way some stuff is wonky with updating. I think it works a little better with one of the “force extra updates” options checked on under “Relations extras” for the particular object the material is applied upon.

Thank you all for your help.

I made it like this:

  1. I changed the Node setup and put a Valuenode BewusstheitsGrad which is linked with the H Value of the Combine HSV-Node
  2. With the following code I can access the Value:

import bpy

bpy.data.node_groups[‘Bewusstheit’].nodes[‘BewusstheitsGrad’].outputs[0].default_value = 1

The thread is SOLVED

Try this instead:http://pasteall.org/blend/index.php?id=46283
(a little better organized)

On the tool shelf, you have a ‘Nodegroup Hue Changer’ panel, with a float prop
Changin that value, will automatically change the ‘Hue’ input of the ‘Hue Saturation Value’ node inside the nodegroup, that is shared over all materials (which are different)

For changing other value than ‘Hue’, you can change the 5th line of the script
[…]nodes[‘Hue Saturation Value’].inputs[‘Saturation’].default_value = …