1
$\begingroup$

I'm sure you've all had enough of me by now, but I need to get this working, so I'm just going to power through.

Is there a way to get this:

enter image description here

into my addon menu?

Ideally it should be hidden by default, and activate with this bool:

mat = bpy.data.materials["Skin"]
nodes = mat.node_tree.nodes
curve = bpy.data.materials["Skin"].node_tree.nodes["DarkCurve"]
BSDF = bpy.data.materials["Skin"].node_tree.nodes["Principled BSDF"]
mainmix = bpy.data.materials["Skin"].node_tree.nodes["MainMix"]

def dark_switch(self, context):
    for tex in bpy.data.materials:
        if (self.my_bool == True):
            #print ("Property Enabled")
            mat.node_tree.links.new(curve.outputs[0], BSDF.inputs[0])
            bpy.data.materials["Skin"].node_tree.nodes["DarkLight"].blend_type = 'LIGHTEN'
        else:
            #print ("Property Disabled")
            mat.node_tree.links.new(mainmix.outputs[0], BSDF.inputs[0])
            bpy.data.materials["Skin"].node_tree.nodes["DarkLight"].blend_type = 'DARKEN'
            
            
# ------------------------------------------------------------------------
#    Scene Properties
# ------------------------------------------------------------------------

class MyProperties(PropertyGroup):

    my_bool: BoolProperty(
        name="DarkSkin",
        description="Tick for Dark Skin",
        default = False,
        update = dark_switch
        )

Which I figured out yesterday, and works perfectly for what it currently does.

$\endgroup$
2
  • $\begingroup$ Please be more specific, what do you mean by "this"? Do you want to show the curve widget? Add a curve node in a shader? $\endgroup$
    – lukas_t
    Jun 25, 2022 at 8:07
  • $\begingroup$ The widget, I suppose. You know when you select a node in the editor it shows up on the side bar in that window? As in my example pic. I need that. I also need the same for some colorramp nodes eventually, I'm hoping if I get one working I'll be able to figure out both. $\endgroup$ Jun 25, 2022 at 16:38

1 Answer 1

1
$\begingroup$

I figured it out, after a lot of poking around in the API docs.

curve = bpy.data.materials["Skin"].node_tree.nodes["RGBCurve"]
layout.template_curve_mapping(curve, "mapping", type='COLOR')

It shows up perfectly, and updates live.

The only thing I don't have it doing is hiding until the tick box is activated. I'd appreciate any advice on that.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .