2
$\begingroup$

I have a Mix RGB node and want to display the input in a normal panel in the UI. I can show the color widget by using layout.prop(input,"default_value"), but what I want to do is to just show the Value of the input. This would then show a float input instead of the color widget.

$\endgroup$
3
$\begingroup$

Use the indexed element, eg red is index 0

enter image description here

For array properties can display an individual element in a layout.prop(...) by specifying the index of the array element. Eg for the red channel of mix color input input.default_value

layout.prop(input, "default_value", index=0)

The color node socket input has a type 'RGBA'

def draw(self, context):
    layout = self.layout
    # node for testing
    node = bpy.data.materials["Material"].node_tree.nodes["Mix"]
    input = node.inputs["Color1"]
    col = layout.column(align=True)
    for i, c in enumerate(input.type): 
        col.prop(
                input, "default_value", 
                text=c.upper(),
                index=i)
| improve this answer | |
$\endgroup$
0
$\begingroup$

What about using a label? I haven't tested the following, but something like this:

value_string = "({:.1f}, {:.1f}, {:.1f})".format(
                                    input.default_value[0],
                                    input.default_value[1],
                                    input.default_value[2])

layout.label(text=value_string)
| improve this answer | |
$\endgroup$
  • $\begingroup$ This just displays the different values. What I want, is to display the Value as in HueSaturationValue as a layout.prop(...) $\endgroup$ – Joshua Knauber May 1 '19 at 19:09
  • 1
    $\begingroup$ There may be a better way, but what about creating three new float properties and having some python set the node color when they are changed? $\endgroup$ – gandalf3 May 1 '19 at 19:14
  • $\begingroup$ Yeah I guess that'd be possible, I hoped there was a better way, but maybe I just have to do that. $\endgroup$ – Joshua Knauber May 1 '19 at 19:29

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.