0
$\begingroup$

It there an example of setting the parent of one shaderNode with another?

Here I am trying to make the Bsdf Principled Node the parent of the Material Output node.

    mat = bpy.data.materials.new(mat_name)
    mat.use_nodes = True
    nodes = mat.node_tree.nodes
    m = nodes['Material Output']
    d = nodes.new('ShaderNodeBsdfPrincipled')
    mat.node_tree.links.new(d.outputs['BSDF'], m.inputs['Surface']) 

    d = nodes['Principled BSDF']

    m.parent = d

When I check the value of m.parent before the assignment and after the assignment the value returned on None

I would have thought that the parenting and child process of Node should be intrinsically built into blender and if something has an output that comes from an input the parent/child relationship. I suspect blender only fills that in when you edit it through the GUI and not via python.

$\endgroup$

Your Answer

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

Browse other questions tagged or ask your own question.