2
$\begingroup$

I have a material on one object and I need to copy it to another object.

I do ... material.copy () but the group node in the material copy does not become a single-user copy. How can this problem be solved?

enter image description here

$\endgroup$
2
$\begingroup$

The copy function can be used on the node tree as well. The copy function returns the copied node group, so it can be used replace the original group with the single user copy:

original_group = bpy.context.objects['Object'].material_slots['Material'].material.node_tree.nodes['Baking_node'].node_tree
single_user_group = original_group.copy()
original_group = single_user_group 

Then just loop that over all your materials

$\endgroup$
1
  • $\begingroup$ Use bpy.context.object for the context object, bpy.context.scene.objects.get("Object") for an object named "Object" in the context scene. There is no context.objects. $\endgroup$ – batFINGER Mar 2 at 4:39

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.