-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathconnectNodes.py
More file actions
33 lines (22 loc) · 806 Bytes
/
connectNodes.py
File metadata and controls
33 lines (22 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#This Source Code Form is subject to the terms of the Mozilla Public
#License, v. 2.0. If a copy of the MPL was not distributed with this
#file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#Created by Fabrice Fernandez on 18/07/2019.
from NatronEngine import *
from NatronGui import *
def connectNodes():
# get current Natron instance running in memory #
app = natron.getGuiInstance(0)
# get selected nodes #
selectedNodes = app.getSelectedNodes()
numNodes = len(selectedNodes)
lastIndex = numNodes - 1
lastNode = selectedNodes[lastIndex]
counter = 0
for currentNode in selectedNodes:
if numNodes >1 :
if counter != lastIndex:
currentNode.disconnectInput(0)
if currentNode.canConnectInput(0,lastNode) == 1:
currentNode.connectInput(0,lastNode)
counter += 1