I have an model with an armature. On several bones are custom properties which are used in drivers.
At the end, the model and the armature should be linked in another scene and the custom properties are used to control certain functions of the model.

My problem now is that I want to control a color of an material node by means of a custom property. For that I added the hex value of the color to the property to use this value in a corresponding driver which should set the color of the material node. But the variables in the driver only accept numeric values and hex is a string. Is there any other way to control a color in a linked object?

Blender 2.75, on Windows

  • $\begingroup$ Is your goal to change colors continuously on every frame? Is your goal to select between a limited set of colors, say 10 colors. Can you show your custom properties in a screen capture or python? $\endgroup$ – atomicbezierslinger Sep 3 '15 at 2:05
  • $\begingroup$ The colors should be set freely, a set is not enough. $\endgroup$ – George Miller Sep 3 '15 at 14:29
  • $\begingroup$ Can you provide an estimate of the number of colors? 5,10,15,800? The number of colors may impact how the python script is written. $\endgroup$ – atomicbezierslinger Sep 3 '15 at 15:35
  • $\begingroup$ Add your own function into driver space that converts hex to int - int('aabbcc',16) then use your function in the scripted expression. $\endgroup$ – sambler Sep 3 '15 at 16:07
  • $\begingroup$ AFAIK you need to drive the RGBA values individually. If you are into scripting you could set up a color vector property and drive each with each value. Othewise set up a custom property for each channel. $\endgroup$ – batFINGER Sep 3 '15 at 17:16

As you have found the Driver values that you can setup to use in your python expressions are limited to float values. Instead of setting a hex value you can setup three float values, one for red, one for blue and one for green.

Select the relevant bone you want to hold your colour settings and create three properties, for simplicity I will name then red, green and blue.

Add a driver to the colour swatch in your material (this can be used for either BI or cycles materials) and setup the driver to to get a single property from the rig and enter the path as pose.bones["ear.l"]["red"] - adjusting the bone name to suit. Repeat for each colour channel.

enter image description here

To make it more user friendly you can also setup a panel to display these properties at the side of the 3dview.

Here is an example file setup.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.