MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / copy_node_graph

Method copy_node_graph

src/bonsai/bonsai/tool/blender.py:438–463  ·  view source on GitHub ↗
(cls, material_to: bpy.types.Material, material_from: bpy.types.Material)

Source from the content-addressed store, hash-verified

436
437 @classmethod
438 def copy_node_graph(cls, material_to: bpy.types.Material, material_from: bpy.types.Material) -> None:
439 temp_override = cls.get_shader_editor_context()
440 shader_editor = temp_override["space"]
441
442 # remove all nodes from the current material
443 for n in material_to.node_tree.nodes[:]:
444 material_to.node_tree.nodes.remove(n)
445
446 previous_pin_setting = shader_editor.pin
447 # required to be able to change material to something else
448 shader_editor.pin = True
449 shader_editor.node_tree = material_from.node_tree
450
451 # select all nodes and copy them to clipboard
452 for node in material_from.node_tree.nodes:
453 node.select = True
454 with bpy.context.temp_override(**temp_override):
455 bpy.ops.node.clipboard_copy()
456
457 # back to original material
458 shader_editor.node_tree = material_to.node_tree
459 with bpy.context.temp_override(**temp_override):
460 bpy.ops.node.clipboard_paste(offset=(0, 0))
461
462 # restore shader editor settings
463 shader_editor.pin = previous_pin_setting
464
465 @classmethod
466 def get_material_node(

Callers 2

test_runMethod · 0.80
executeMethod · 0.80

Calls 2

removeMethod · 0.45

Tested by 1

test_runMethod · 0.64