mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
use Action.perform copy() to copy nodes
This commit is contained in:
parent
7394e7284a
commit
0f32a6d056
1 changed files with 11 additions and 9 deletions
|
|
@ -151,28 +151,31 @@ def application_launch():
|
||||||
def export_template(backdrops, nodes, filepath):
|
def export_template(backdrops, nodes, filepath):
|
||||||
func = """function func(args)
|
func = """function func(args)
|
||||||
{
|
{
|
||||||
scene.beginUndoRedoAccum("Publish: export template");
|
|
||||||
// Add an extra node just so a new group can be created.
|
|
||||||
var temp_node = node.add("Top", "temp_note", "NOTE", 0, 0, 0);
|
var temp_node = node.add("Top", "temp_note", "NOTE", 0, 0, 0);
|
||||||
var template_group = node.createGroup(temp_node, "temp_group");
|
var template_group = node.createGroup(temp_node, "temp_group");
|
||||||
node.deleteNode( template_group + "/temp_note" );
|
node.deleteNode( template_group + "/temp_note" );
|
||||||
|
|
||||||
// This will make Node View to focus on the new group.
|
selection.clearSelection();
|
||||||
|
for (var f = 0; f < args[1].length; f++)
|
||||||
|
{
|
||||||
|
selection.addNodeToSelection(args[1][f]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Action.perform("copy()", "Node View");
|
||||||
|
|
||||||
selection.clearSelection();
|
selection.clearSelection();
|
||||||
selection.addNodeToSelection(template_group);
|
selection.addNodeToSelection(template_group);
|
||||||
Action.perform("onActionEnterGroup()", "Node View");
|
Action.perform("onActionEnterGroup()", "Node View");
|
||||||
|
Action.perform("paste()", "Node View");
|
||||||
|
|
||||||
// Recreate backdrops in group.
|
// Recreate backdrops in group.
|
||||||
for (var i = 0 ; i < args[0].length; i++)
|
for (var i = 0 ; i < args[0].length; i++)
|
||||||
{
|
{
|
||||||
|
MessageLog.trace(args[0][i]);
|
||||||
Backdrop.addBackdrop(template_group, args[0][i]);
|
Backdrop.addBackdrop(template_group, args[0][i]);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Copy-paste the selected nodes into the new group.
|
|
||||||
var drag_object = copyPaste.copy(args[1], 1, frame.numberOf(), "");
|
|
||||||
copyPaste.pasteNewNodes(drag_object, template_group, "");
|
|
||||||
|
|
||||||
// Select all nodes within group and export as template.
|
|
||||||
Action.perform( "selectAll()", "Node View" );
|
Action.perform( "selectAll()", "Node View" );
|
||||||
copyPaste.createTemplateFromSelection(args[2], args[3]);
|
copyPaste.createTemplateFromSelection(args[2], args[3]);
|
||||||
|
|
||||||
|
|
@ -180,7 +183,6 @@ def export_template(backdrops, nodes, filepath):
|
||||||
// created during the process.
|
// created during the process.
|
||||||
Action.perform("onActionUpToParent()", "Node View");
|
Action.perform("onActionUpToParent()", "Node View");
|
||||||
node.deleteNode(template_group, true, true);
|
node.deleteNode(template_group, true, true);
|
||||||
scene.cancelUndoRedoAccum();
|
|
||||||
}
|
}
|
||||||
func
|
func
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue