I'm doing a loop to connect a bunch of color masks to blend nodes via python loop , but the connection occurs randomly and nost in order as one would expect... what's wrong?
this is the code
import sd
from PySide2 import QtGui
from sd.api.sduimgr import SDUIMgr
from sd.api.sdproperty import SDPropertyCategory
from sd.api.sdapplication import SDApplicationPath
class CompNodeCreator(object):
def __init__(self):
# Get app and UI manager.
ctx = sd.getContext()
app = ctx.getSDApplication()
self.ui_manager = app.getQtForPythonUIMgr()
def add_node(self, name, pos):
# Get the comp graph.
sd_graph = self.ui_manager.getCurrentGraph()
# Create a node.
node_def_id = 'sbs::compositing::{definition}'.format(definition=name)
sd_node = sd_graph.newNode(node_def_id)
sd_node.setPosition( sd.api.sdbasetypes.float2(pos[0],pos[1]))
return sd_node
# Run
def NodeProps(node):
nodePropsA = node.getProperties(SDPropertyCategory.Output)
for i in range(len(nodePropsA)):
print(nodePropsA[i].getId())
print(nodePropsA[i].getType())
nodePropsB = node.getProperties(SDPropertyCategory.Input)
for i in range(len(nodePropsB)):
print(nodePropsB[i].getId())
print(nodePropsB[i].getType())
selection = uiMgr.getCurrentGraphSelection()
i = 300
i2 = 0
pos = [0,0]
n = {}
for e,node in enumerate(selection):
print(pos)
print(str(e))
name = 'blend'
blend = node_creator.add_node(name,pos)
node.newPropertyConnectionFromId('output', blend ,'opacity')
pos[0] += i2
pos[1] += i