@BYOB @AFWS
I finally was able to create a node setup from only script commands. Here is my result:
I have the script below, is there a
efficient and more
shorter way to do the same job?
import bpy
bpy.context.area.ui_type = 'CompositorNodeTree'
scene = bpy.context.scene
nodetree = scene.node_tree
# adding movie clip node 1
node1 = nodetree.nodes.new("CompositorNodeMovieClip")
bpy.ops.node.translate_attach(TRANSFORM_OT_translate={"value":(0, 200, 0), "orient_type":'GLOBAL', "orient_matrix":((1, 0, 0), (0, 1, 0), (0, 0, 1)), "orient_matrix_type":'GLOBAL', "constraint_axis":(False, False, False), "mirror":True, "use_proportional_edit":False, "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "use_proportional_connected":False, "use_proportional_projected":False, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "cursor_transform":False, "texture_space":False, "remove_on_cancel":False, "release_confirm":False, "use_accurate":False}, NODE_OT_attach={}, NODE_OT_insert_offset={})
bpy.ops.node.select_all(action='DESELECT')
# adding movie clip 2
node2 = nodetree.nodes.new("CompositorNodeMovieClip")
bpy.ops.node.translate_attach(TRANSFORM_OT_translate={"value":(0, -200, 0), "orient_type":'GLOBAL', "orient_matrix":((1, 0, 0), (0, 1, 0), (0, 0, 1)), "orient_matrix_type":'GLOBAL', "constraint_axis":(False, False, False), "mirror":True, "use_proportional_edit":False, "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "use_proportional_connected":False, "use_proportional_projected":False, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "cursor_transform":False, "texture_space":False, "remove_on_cancel":False, "release_confirm":False, "use_accurate":False}, NODE_OT_attach={}, NODE_OT_insert_offset={})
bpy.ops.node.select_all(action='DESELECT')
# adding alphaover node
node3 = nodetree.nodes.new("CompositorNodeAlphaOver")
bpy.ops.node.translate_attach(TRANSFORM_OT_translate={"value":(500, 0, 0), "orient_type":'GLOBAL', "orient_matrix":((1, 0, 0), (0, 1, 0), (0, 0, 1)), "orient_matrix_type":'GLOBAL', "constraint_axis":(False, False, False), "mirror":True, "use_proportional_edit":False, "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "use_proportional_connected":False, "use_proportional_projected":False, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "cursor_transform":False, "texture_space":False, "remove_on_cancel":False, "release_confirm":False, "use_accurate":False}, NODE_OT_attach={}, NODE_OT_insert_offset={})
bpy.ops.node.select_all(action='DESELECT')
# adding mask node
node4 = nodetree.nodes.new("CompositorNodeMask")
bpy.ops.node.translate_attach(TRANSFORM_OT_translate={"value":(200, 100, 0), "orient_type":'GLOBAL', "orient_matrix":((1, 0, 0), (0, 1, 0), (0, 0, 1)), "orient_matrix_type":'GLOBAL', "constraint_axis":(False, False, False), "mirror":True, "use_proportional_edit":False, "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "use_proportional_connected":False, "use_proportional_projected":False, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "cursor_transform":False, "texture_space":False, "remove_on_cancel":False, "release_confirm":False, "use_accurate":False}, NODE_OT_attach={}, NODE_OT_insert_offset={})
bpy.ops.node.select_all(action='DESELECT')
# adding compositor node
node5 = nodetree.nodes.new("CompositorNodeComposite")
bpy.ops.node.translate_attach(TRANSFORM_OT_translate={"value":(1000, 0, 0), "orient_type":'GLOBAL', "orient_matrix":((1, 0, 0), (0, 1, 0), (0, 0, 1)), "orient_matrix_type":'GLOBAL', "constraint_axis":(False, False, False), "mirror":True, "use_proportional_edit":False, "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "use_proportional_connected":False, "use_proportional_projected":False, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "cursor_transform":False, "texture_space":False, "remove_on_cancel":False, "release_confirm":False, "use_accurate":False}, NODE_OT_attach={}, NODE_OT_insert_offset={})
bpy.ops.node.select_all(action='DESELECT')
# connecting nodes
nodetree.links.new(node1.outputs["Image"],node3.inputs[1])
nodetree.links.new(node2.outputs["Image"],node3.inputs[2])
nodetree.links.new(node4.outputs["Mask"],node3.inputs[0])
nodetree.links.new(node3.outputs["Image"],node5.inputs[0])
bpy.context.area.ui_type = 'TEXT_EDITOR'
To translate the node to different position do I have to use this long piece of code always?
bpy.ops.node.translate_attach(TRANSFORM_OT_translate={“value”:(1000, 0, 0), “orient_type”:‘GLOBAL’, “orient_matrix”:((1, 0, 0), (0, 1, 0), (0, 0, 1)), “orient_matrix_type”:‘GLOBAL’, “constraint_axis”:(False, False, False), “mirror”:True, “use_proportional_edit”:False, “proportional_edit_falloff”:‘SMOOTH’, “proportional_size”:1, “use_proportional_connected”:False, “use_proportional_projected”:False, “snap”:False, “snap_target”:‘CLOSEST’, “snap_point”:(0, 0, 0), “snap_align”:False, “snap_normal”:(0, 0, 0), “gpencil_strokes”:False, “cursor_transform”:False, “texture_space”:False, “remove_on_cancel”:False, “release_confirm”:False, “use_accurate”:False}, NODE_OT_attach={}, NODE_OT_insert_offset={})